Add test for N-D warping

This commit is contained in:
Johannes Schönberger
2014-09-18 21:03:56 -04:00
parent f5c627493e
commit 877a7ba109
+19
View File
@@ -55,6 +55,25 @@ def test_warp_matrix():
outx = warp(x, matrix, order=5)
def test_warp_nd():
for dim in range(2, 8):
shape = dim * (5,)
x = np.zeros(shape, dtype=np.double)
x_c = dim * (2,)
x[x_c] = 1
refx = np.zeros(shape, dtype=np.double)
refx_c = dim * (1,)
refx[refx_c] = 1
coord_grid = dim * (np.arange(5),)
coords = np.array(np.meshgrid(*coord_grid)) + 1
outx = warp(x, coords, order=0, cval=0)
assert_array_almost_equal(outx, refx)
def test_warp_clip():
x = 2 * np.ones((5, 5), dtype=np.double)
matrix = np.eye(3)