Remove repeated coordinates before computing convex hull

This commit is contained in:
Juan Nunez-Iglesias
2013-08-05 09:42:23 +10:00
parent 640c49608d
commit a6ec1741dc
+4
View File
@@ -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