mirror of
https://github.com/wassname/scikit-image.git
synced 2026-08-12 12:30:16 +08:00
Add support for matrix as inverse_map
This commit is contained in:
@@ -11,10 +11,9 @@ from skimage import transform as tf, data, img_as_float
|
||||
from skimage.color import rgb2gray
|
||||
|
||||
|
||||
def test_warp():
|
||||
x = np.zeros((5, 5), dtype=np.uint8)
|
||||
x[2, 2] = 255
|
||||
x = img_as_float(x)
|
||||
def test_warp_tform():
|
||||
x = np.zeros((5, 5), dtype=np.double)
|
||||
x[2, 2] = 1
|
||||
theta = - np.pi / 2
|
||||
tform = SimilarityTransform(scale=1, rotation=theta, translation=(0, 4))
|
||||
|
||||
@@ -25,10 +24,36 @@ def test_warp():
|
||||
assert_array_almost_equal(x90, np.rot90(x))
|
||||
|
||||
|
||||
def test_warp_callable():
|
||||
x = np.zeros((5, 5), dtype=np.double)
|
||||
x[2, 2] = 1
|
||||
refx = np.zeros((5, 5), dtype=np.double)
|
||||
refx[1, 1] = 1
|
||||
|
||||
shift = lambda xy: xy + 1
|
||||
|
||||
outx = warp(x, shift, order=1)
|
||||
assert_array_almost_equal(outx, refx)
|
||||
|
||||
|
||||
def test_warp_matrix():
|
||||
x = np.zeros((5, 5), dtype=np.double)
|
||||
x[2, 2] = 1
|
||||
refx = np.zeros((5, 5), dtype=np.double)
|
||||
refx[1, 1] = 1
|
||||
|
||||
matrix = np.array([[1, 0, 1], [0, 1, 1], [0, 0, 1]])
|
||||
|
||||
# _warp_fast
|
||||
outx = warp(x, matrix, order=1)
|
||||
assert_array_almost_equal(outx, refx)
|
||||
# check for ndimage.map_coordinates
|
||||
outx = warp(x, matrix, order=5)
|
||||
|
||||
|
||||
def test_homography():
|
||||
x = np.zeros((5, 5), dtype=np.uint8)
|
||||
x[1, 1] = 255
|
||||
x = img_as_float(x)
|
||||
x = np.zeros((5, 5), dtype=np.double)
|
||||
x[1, 1] = 1
|
||||
theta = -np.pi / 2
|
||||
M = np.array([[np.cos(theta), - np.sin(theta), 0],
|
||||
[np.sin(theta), np.cos(theta), 4],
|
||||
|
||||
Reference in New Issue
Block a user