From afb479d766ccb97291acae27afd484a63c28c7e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Scho=CC=88nberger?= Date: Sun, 15 Jul 2012 17:51:34 +0200 Subject: [PATCH] geometric_transform can transform single coordinate tuple --- skimage/transform/geometric.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/skimage/transform/geometric.py b/skimage/transform/geometric.py index edb3d014..2051e241 100644 --- a/skimage/transform/geometric.py +++ b/skimage/transform/geometric.py @@ -43,13 +43,22 @@ def geometric_transform(coords, matrix): coords : Nx2 array transformed coordinates """ + coords = np.asarray(coords) + shape = coords.shape + if shape == (2,): + coords = np.array([coords]) + x, y = np.transpose(coords) src = np.vstack((x, y, np.ones_like(x))) dst = np.dot(src.transpose(), matrix.transpose()) # rescale to homogeneous coordinates dst[:, 0] /= dst[:, 2] dst[:, 1] /= dst[:, 2] - return dst[:, :2] + + if shape == (2,): + return dst[0, :2] + else: + return dst[:, :2] class GeometricTransformation(object):