mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-10 08:36:37 +08:00
Merge pull request #1828 from stefanv/radon_circle_warn
radon transform: ignore values outside circle
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user