QH6228 Bug fix - remove offset from coords

This commit is contained in:
Jeremy Metz
2014-01-31 13:46:28 +00:00
parent 73bf701b5c
commit add4b51db7
+7
View File
@@ -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)