mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-23 13:10:18 +08:00
QH6228 Bug fix - remove offset from coords
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user