Improve conditioning of homography design matrix

This commit is contained in:
Johannes Schönberger
2014-12-24 15:24:34 +01:00
parent 2f60de7362
commit 983919404f
+7
View File
@@ -264,6 +264,10 @@ class ProjectiveTransform(GeometricTransform):
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]
@@ -296,6 +300,9 @@ class ProjectiveTransform(GeometricTransform):
H.flat[list(self._coeffs) + [8]] = - V[-1, :-1] / V[-1, -1]
H[2, 2] = 1
# De-center and de-normalize
H = np.dot(np.linalg.inv(dst_matrix), np.dot(H, src_matrix))
self.params = H
def __add__(self, other):