Improve conditioning of silimarity transform design matrix

This commit is contained in:
Johannes Schönberger
2015-01-21 14:10:09 -05:00
parent 983919404f
commit 5dbb6e3257
+13 -3
View File
@@ -651,6 +651,10 @@ class SimilarityTransform(ProjectiveTransform):
Destination coordinates.
"""
src_matrix, src = _center_and_normalize_points(src)
dst_matrix, dst = _center_and_normalize_points(dst)
xs = src[:, 0]
ys = src[:, 1]
xd = dst[:, 0]
@@ -674,9 +678,15 @@ class SimilarityTransform(ProjectiveTransform):
# singular value
a0, a1, b0, b1 = - V[-1, :-1] / V[-1, -1]
self.params = np.array([[a0, -b0, a1],
[b0, a0, b1],
[ 0, 0, 1]])
S = np.array([[a0, -b0, a1],
[b0, a0, b1],
[ 0, 0, 1]])
# De-center and de-normalize
S = np.dot(np.linalg.inv(dst_matrix), np.dot(S, src_matrix))
self.params = S
@property
def scale(self):