8000 Why is morphology.convex_hull_object 2D only? · Issue #4865 · scikit-image/scikit-image · GitHub
[go: up one dir, main page]

Skip to content

Why is morphology.convex_hull_object 2D only? #4865

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
emmanuelle opened this issue Jul 29, 2020 · 2 comments
Open

Why is morphology.convex_hull_object 2D only? #4865

emmanuelle opened this issue Jul 29, 2020 · 2 comments
Labels
🍺 Hacktoberfest 🔰 Good first issue A good task for those new to the library 🐛 Bug

Comments

@emmanuelle
Copy link
Member

Currently calling morphology.convex_hull_object on a 3D binary image fails because of a specific 2D check but when this part is commented out, the function returns something which looked reasonable to me from a quick test. morphology.convex_hull_image is compatible with 3D images.

@jni jni added the 🔰 Good first issue A good task for those new to the library label Jul 30, 2020
@jni
Copy link
Member
jni commented Jul 30, 2020

Needless to say, I support removing this check! I imagine it dates from the time when convex_hull_image was not compatible with 3D images.

@s-sajid-ali
Copy link
s-sajid-ali commented Oct 17, 2020

After removing the lines 131-132 here I tried testing the convex_hull_object function on the image3d array from here. With connectivity=2, it works but with connectivity=1 it fails.

The measure.label routine generates two objects for connectivity=1 (3d objects with repeating 2d structures as shown below):
image while the (only) object generated for connectivity=2 includes the lone point (since it has diagonal connectivity).

The following error occurs in computing the convex_hull_image for second labeled array :

---------------------------------------------------------------------------
QhullError                                Traceback (most recent call last)
<ipython-input-50-5e4db18196b2> in <module>
----> 1 res = morphology.convex_hull_object(image3d, connectivity=1)

~/miniconda3/envs/py38/lib/python3.8/site-packages/skimage/morphology/convex_hull.py in convex_hull_object(image, connectivity)
    137 
    138     for i in range(1, labeled_im.max() + 1):
--> 139         convex_obj = convex_hull_image(labeled_im == i)
    140         convex_img = np.logical_or(convex_img, convex_obj)
    141 

~/miniconda3/envs/py38/lib/python3.8/site-packages/skimage/morphology/convex_hull.py in convex_hull_image(image, offset_coordinates, tolerance)
     64             # therefore, we reduce the number of coordinates by using a
     65             # convex hull on the original set, before offsetting.
---> 66             hull0 = ConvexHull(coords)
     67             coords = hull0.points[hull0.vertices]
     68 

qhull.pyx in scipy.spatial.qhull.ConvexHull.__init__()

qhull.pyx in scipy.spatial.qhull._Qhull.__init__()

QhullError: QH6214 qhull input error: not enough points(3) to construct initial simplex (need 4)

While executing:  | qhull i Qt
Options selected for Qhull 2019.1.r 2019/06/21:
  run-id 799427754  incidence  Qtriangulate  _pre-merge  _zero-centrum
  _maxoutside  0

A similar error occurs in 2D if only 2 points are passed to ConvexHull. Should an extra check be added in convex_hull_image that checks the length of coords before calling ConvexHull ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍺 Hacktoberfest 🔰 Good first issue A good task for those new to the library 🐛 Bug
Projects
None yet
Development

No branches or pull requests

6 participants
0