mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-25 13:30:51 +08:00
transform.radon: Consistent definition of center of array.
The center is now defined as shape[i] // 2.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user