From bf2a5a429b5853a08ab3a18b261c0deb848e59f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 1 May 2013 12:57:30 +0200 Subject: [PATCH] Add residuals method to geometric transforms --- skimage/transform/_geometric.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/skimage/transform/_geometric.py b/skimage/transform/_geometric.py index 4b2a38d5..1fcb55bb 100644 --- a/skimage/transform/_geometric.py +++ b/skimage/transform/_geometric.py @@ -61,6 +61,28 @@ class GeometricTransform(object): # well- and over-determined. return False + def residuals(self, src, dst): + """Determine residuals of transformed destination coordinates. + + For each transformed source coordinate the euclidean distance to the + respective destination coordinate is determined. + + Parameters + ---------- + src : (N, 2) array + Source coordinates. + dst : (N, 2) array + Destination coordinates. + + Returns + ------- + residuals : (N, ) array + Residual for coordinate. + + """ + + return np.sqrt(np.sum((self(src) - dst) ** 2, axis=1)) + def __add__(self, other): """Combine this transformation with another.