mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-02 13:24:06 +08:00
transform.radon: Add test to verify the projection center.
This test is designed for issue gh-592.
This commit is contained in:
@@ -3,6 +3,7 @@ from __future__ import division
|
||||
|
||||
import numpy as np
|
||||
from numpy.testing import *
|
||||
from numpy.fft import ifftshift, ifftn
|
||||
import itertools
|
||||
from skimage.transform import *
|
||||
|
||||
@@ -14,6 +15,30 @@ def rescale(x):
|
||||
return 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.
|
||||
# Calculate the sinogram
|
||||
theta = np.linspace(0., 180., max(shape), endpoint=False)
|
||||
sinogram = radon(image, theta=theta, circle=circle)
|
||||
# The sinogram should be a straight, horizontal line
|
||||
sinogram_max = np.argmax(sinogram, axis=0)
|
||||
print(sinogram_max)
|
||||
assert np.std(sinogram_max) < 1e-6
|
||||
|
||||
|
||||
def test_radon_center():
|
||||
shapes = [(16, 16), (17, 17)]
|
||||
circles = [False, True]
|
||||
for shape, circle in itertools.product(shapes, circles):
|
||||
yield check_radon_center, shape, circle
|
||||
|
||||
|
||||
def test_radon_iradon():
|
||||
size = 100
|
||||
debug = False
|
||||
|
||||
Reference in New Issue
Block a user