mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-09 07:11:31 +08:00
change interface of transformation merging
This commit is contained in:
@@ -105,18 +105,15 @@ class GeometricTransformation(object):
|
||||
self.inverse_matrix = np.linalg.inv(self.matrix)
|
||||
return geometric_transform(coords, self.inverse_matrix)
|
||||
|
||||
def union(self, other):
|
||||
def __mul__(self, other):
|
||||
if type(self) == type(other):
|
||||
transformation = self.__class__
|
||||
else:
|
||||
transformation = GeometricTransformation
|
||||
return transformation(self.matrix.dot(other.matrix))
|
||||
|
||||
def __mul__(self, other):
|
||||
return self.union(other)
|
||||
|
||||
def __add__(self, other):
|
||||
return self.union(other)
|
||||
return self.__mul__(other)
|
||||
|
||||
|
||||
class SimilarityTransformation(GeometricTransformation):
|
||||
@@ -424,15 +421,6 @@ class PolynomialTransformation(GeometricTransformation):
|
||||
'parameters by exchanging source and destination coordinates.'
|
||||
'Then apply the forward transformation.')
|
||||
|
||||
def union(self, other):
|
||||
raise Exception('Cannot unite polynomial transformations.')
|
||||
|
||||
def __mul__(self, other):
|
||||
return self.union(self, other)
|
||||
|
||||
def __add__(self, other):
|
||||
return self.union(self, other)
|
||||
|
||||
|
||||
TRANSFORMATIONS = {
|
||||
'similarity': SimilarityTransformation,
|
||||
|
||||
@@ -135,7 +135,6 @@ def test_union():
|
||||
translation2 = (0, 0)
|
||||
tform2.from_params(scale2, rotation2, translation2)
|
||||
|
||||
tform = tform1.union(tform2)
|
||||
tform = tform1 + tform2
|
||||
tform = tform1 * tform2
|
||||
|
||||
|
||||
Reference in New Issue
Block a user