def __call__(self, img: np.ndarray): """ Args: img: numpy.ndarray containing input data. Must be real and in shape [channels, spatial1, spatial2, ...]. Returns: np.ndarray containing smoothed result. """ # add one to transform axis because a batch axis will be added at dimension 0 savgol_filter = SavitzkyGolayFilter(self.window_length, self.order, self.axis + 1, self.mode) # convert to Tensor and add Batch axis expected by HilbertTransform input_data = torch.as_tensor(np.ascontiguousarray(img)).unsqueeze(0) return savgol_filter(input_data).squeeze(0).numpy()
def test_value(self, arguments, image, expected_data, atol, rtol=1e-5): result = SavitzkyGolayFilter(**arguments)(image.to(device="cuda")) np.testing.assert_allclose(result.cpu(), expected_data, atol=atol, rtol=rtol)
def test_value(self, arguments, image, expected_data, atol): result = SavitzkyGolayFilter(**arguments)(image) np.testing.assert_allclose(result, expected_data, atol=atol)