mirror of
https://github.com/wassname/scikit-image.git
synced 2026-06-30 11:44:53 +08:00
Test 90deg rotation for similarity transform
This commit is contained in:
@@ -620,9 +620,9 @@ class SimilarityTransform(ProjectiveTransform):
|
||||
|
||||
@property
|
||||
def scale(self):
|
||||
if math.cos(self.rotation) == 0:
|
||||
if abs(math.cos(self.rotation)) < np.spacing(1):
|
||||
# sin(self.rotation) == 1
|
||||
scale = self.params[0, 1]
|
||||
scale = self.params[1, 0]
|
||||
else:
|
||||
scale = self.params[0, 0] / math.cos(self.rotation)
|
||||
return scale
|
||||
|
||||
@@ -99,6 +99,17 @@ def test_similarity_init():
|
||||
assert_array_almost_equal(tform.translation, translation)
|
||||
|
||||
|
||||
# test special case for scale if rotation=90deg
|
||||
scale = 0.1
|
||||
rotation = np.pi / 2
|
||||
translation = (1, 1)
|
||||
tform = SimilarityTransform(scale=scale, rotation=rotation,
|
||||
translation=translation)
|
||||
assert_array_almost_equal(tform.scale, scale)
|
||||
assert_array_almost_equal(tform.rotation, rotation)
|
||||
assert_array_almost_equal(tform.translation, translation)
|
||||
|
||||
|
||||
def test_affine_estimation():
|
||||
# exact solution
|
||||
tform = estimate_transform('affine', SRC[:3, :], DST[:3, :])
|
||||
|
||||
Reference in New Issue
Block a user