From add4b51db7fb2d9adc9d21bc43d57a62c5b14380 Mon Sep 17 00:00:00 2001 From: Jeremy Metz Date: Fri, 31 Jan 2014 13:46:28 +0000 Subject: [PATCH] QH6228 Bug fix - remove offset from coords --- skimage/morphology/convex_hull.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/skimage/morphology/convex_hull.py b/skimage/morphology/convex_hull.py index 1a26b842..6fc08097 100644 --- a/skimage/morphology/convex_hull.py +++ b/skimage/morphology/convex_hull.py @@ -54,6 +54,10 @@ def convex_hull_image(image): raise ImportError('Could not import scipy.spatial, only available in ' 'scipy >= 0.9.') + # Subtract offset + offset = coords.mean(axis=0) + coords -= offset + # Find the convex hull chull = Delaunay(coords).convex_hull v = coords[np.unique(chull)] @@ -63,6 +67,9 @@ def convex_hull_image(image): angles = np.arctan2(v_centred[:, 0], v_centred[:, 1]) v = v[np.argsort(angles)] + # Add back offset + v += offset + # For each pixel coordinate, check whether that pixel # lies inside the convex hull mask = grid_points_inside_poly(image.shape[:2], v)