mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-01 14:19:52 +08:00
Merge pull request #1167 from ahojnnes/inv-comb
Add option to combine tform with inverse tform. Closes gh-1165.
This commit is contained in:
@@ -261,6 +261,10 @@ class ProjectiveTransform(GeometricTransform):
|
||||
else:
|
||||
tform = ProjectiveTransform
|
||||
return tform(other.params.dot(self.params))
|
||||
elif (hasattr(other, '__name__')
|
||||
and other.__name__ == 'inverse'
|
||||
and hasattr(get_bound_method_class(other), '_inv_matrix')):
|
||||
return ProjectiveTransform(self._inv_matrix.dot(self.params))
|
||||
else:
|
||||
raise TypeError("Cannot combine transformations of differing "
|
||||
"types.")
|
||||
@@ -789,6 +793,7 @@ TRANSFORMS = {
|
||||
'projective': ProjectiveTransform,
|
||||
'polynomial': PolynomialTransform,
|
||||
}
|
||||
|
||||
HOMOGRAPHY_TRANSFORMS = (
|
||||
SimilarityTransform,
|
||||
AffineTransform,
|
||||
|
||||
@@ -218,6 +218,9 @@ def test_union():
|
||||
assert_array_almost_equal(tform._matrix, tform3._matrix)
|
||||
assert tform.__class__ == ProjectiveTransform
|
||||
|
||||
tform = AffineTransform(scale=(0.1, 0.1), rotation=0.3)
|
||||
assert_array_almost_equal((tform + tform.inverse).params, np.eye(3))
|
||||
|
||||
|
||||
def test_union_differing_types():
|
||||
tform1 = SimilarityTransform()
|
||||
|
||||
Reference in New Issue
Block a user