mirror of
https://github.com/wassname/scikit-image.git
synced 2026-08-13 12:40:24 +08:00
Add projective transformation / homography.
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import numpy as np
|
||||
from numpy.testing import assert_array_almost_equal
|
||||
|
||||
from scikits.image.transform.project import _stackcopy, homography
|
||||
|
||||
def test_stackcopy():
|
||||
layers = 4
|
||||
x = np.empty((3, 3, layers))
|
||||
y = np.eye(3, 3)
|
||||
_stackcopy(x, y)
|
||||
for i in range(layers):
|
||||
assert_array_almost_equal(x[...,i], y)
|
||||
|
||||
def test_homography():
|
||||
x = np.arange(9).reshape((3, 3)) + 1
|
||||
theta = -np.pi/2
|
||||
M = np.array([[np.cos(theta),-np.sin(theta),0],
|
||||
[np.sin(theta), np.cos(theta),2],
|
||||
[0, 0, 1]])
|
||||
x90 = homography(x, M, order=1)
|
||||
assert_array_almost_equal(x90, np.rot90(x))
|
||||
Reference in New Issue
Block a user