From a44f1d4ef92342027f2901aa77f70e86b98ad1ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jostein=20B=C3=B8=20Fl=C3=B8ystad?= Date: Tue, 18 Jun 2013 18:49:24 +0200 Subject: [PATCH] transform.radon: Consistent definition of center of array. The center is now defined as shape[i] // 2. --- skimage/transform/radon_transform.py | 11 +++++------ skimage/transform/tests/test_radon_transform.py | 6 +----- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/skimage/transform/radon_transform.py b/skimage/transform/radon_transform.py index fffe4e6f..2733e243 100644 --- a/skimage/transform/radon_transform.py +++ b/skimage/transform/radon_transform.py @@ -79,11 +79,10 @@ def radon(image, theta=None, circle=False): widthpad = int(np.ceil(diagonal - width)) padded_image = np.zeros((int(height + heightpad), int(width + widthpad))) - y0 = int(np.ceil(heightpad / 2)) - y1 = int((np.ceil(heightpad / 2) + height)) - x0 = int((np.ceil(widthpad / 2))) - x1 = int((np.ceil(widthpad / 2) + width)) - + y0 = heightpad // 2 + y1 = y0 + height + x0 = widthpad // 2 + x1 = x0 + width padded_image[y0:y1, x0:x1] = image out = np.zeros((max(padded_image.shape), len(theta))) @@ -109,7 +108,7 @@ def radon(image, theta=None, circle=False): for i in range(len(theta)): rotated = _warp_fast(padded_image, build_rotation(theta[i])) - out[:, i] = rotated.sum(0)[::-1] + out[:, i] = rotated.sum(0) return out diff --git a/skimage/transform/tests/test_radon_transform.py b/skimage/transform/tests/test_radon_transform.py index 8e31c658..9a03b1f2 100644 --- a/skimage/transform/tests/test_radon_transform.py +++ b/skimage/transform/tests/test_radon_transform.py @@ -16,13 +16,9 @@ def rescale(x): def check_radon_center(shape, circle): - # Determine the center of an array as defined by the fft - ft_image = np.abs(ifftshift(ifftn(np.ones(shape))))**2 - fft_center = np.unravel_index(np.argmax(ft_image), shape) - print('fft_center =', fft_center) # Create a test image with only a single non-zero pixel at the origin image = np.zeros(shape, dtype=np.float) - image[fft_center] = 1. + image[(shape[0] // 2, shape[1] // 2)] = 1. # Calculate the sinogram theta = np.linspace(0., 180., max(shape), endpoint=False) sinogram = radon(image, theta=theta, circle=circle)