From a6ec1741dcbe3119e0ab8d45dd24ddc1e409cfa1 Mon Sep 17 00:00:00 2001 From: Juan Nunez-Iglesias Date: Mon, 5 Aug 2013 09:42:23 +1000 Subject: [PATCH] Remove repeated coordinates before computing convex hull --- skimage/morphology/convex_hull.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/skimage/morphology/convex_hull.py b/skimage/morphology/convex_hull.py index 28ff204b..b045d7f3 100644 --- a/skimage/morphology/convex_hull.py +++ b/skimage/morphology/convex_hull.py @@ -4,6 +4,7 @@ import numpy as np from ._pnpoly import grid_points_inside_poly from ._convex_hull import possible_hull from skimage.morphology import label +from skimage.util import unique_rows def convex_hull_image(image): @@ -35,6 +36,9 @@ def convex_hull_image(image): # limits the number of coordinates to examine for the virtual # hull. coords = possible_hull(image.astype(np.uint8)) + # repeated coordinates can *sometimes* cause problems in + # scipy.spatial.Delaunay, so we remove them. + coords = unique_rows(coords) N = len(coords) # Add a vertex for the middle of each pixel edge