Add support for matrix as inverse_map

This commit is contained in:
Johannes Schönberger
2013-10-02 17:33:17 +02:00
parent 9741bfda15
commit 40f5e78353
2 changed files with 46 additions and 13 deletions
+32 -7
View File
@@ -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],