From 74a015d1d4770f842c62200818054890898bf292 Mon Sep 17 00:00:00 2001 From: Stefan van der Walt Date: Mon, 14 Dec 2015 17:12:34 -0800 Subject: [PATCH] radon transform: when circle=True, ignore values outside circle without throwing an error (closes #1808) --- skimage/transform/radon_transform.py | 10 +++------- skimage/transform/tests/test_radon_transform.py | 5 +++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/skimage/transform/radon_transform.py b/skimage/transform/radon_transform.py index e49496c1..f71b7566 100644 --- a/skimage/transform/radon_transform.py +++ b/skimage/transform/radon_transform.py @@ -20,6 +20,7 @@ from scipy.interpolate import interp1d from ._warps_cy import _warp_fast from ._radon_transform import sart_projection_update from .. import util +from warnings import warn __all__ = ["radon", "iradon", "iradon_sart"] @@ -49,11 +50,6 @@ def radon(image, theta=None, circle=False): at the pixel index ``radon_image.shape[0] // 2`` along the 0th dimension of ``radon_image``. - Raises - ------ - ValueError - If called with ``circle=True`` and ``image != 0`` outside the inscribed - circle """ if image.ndim != 2: raise ValueError('The input image must be 2-D') @@ -67,8 +63,8 @@ def radon(image, theta=None, circle=False): + (c1 - image.shape[1] // 2) ** 2) reconstruction_circle = reconstruction_circle <= radius ** 2 if not np.all(reconstruction_circle | (image == 0)): - raise ValueError('Image must be zero outside the reconstruction' - ' circle') + warn('Radon transform: image must be zero outside the ' + 'reconstruction circle') # Crop image to make it square slices = [] for d in (0, 1): diff --git a/skimage/transform/tests/test_radon_transform.py b/skimage/transform/tests/test_radon_transform.py index 6df8b7f8..63bfa31f 100644 --- a/skimage/transform/tests/test_radon_transform.py +++ b/skimage/transform/tests/test_radon_transform.py @@ -9,7 +9,7 @@ from skimage.transform import radon, iradon, iradon_sart, rescale from skimage.io import imread from skimage import data_dir from skimage._shared.testing import test_parallel - +from skimage._shared._warnings import expected_warnings PHANTOM = imread(os.path.join(data_dir, "phantom.png"), as_grey=True)[::2, ::2] @@ -215,7 +215,8 @@ def _random_circle(shape): def test_radon_circle(): a = np.ones((10, 10)) - assert_raises(ValueError, radon, a, circle=True) + with expected_warnings(['reconstruction circle']): + radon(a, circle=True) # Synthetic data, circular symmetry shape = (61, 79)