clEsperanto / pyclesperanto_prototype

GPU-accelerated bio-image analysis focusing on 3D+t microscopy image data
http://clesperanto.net
BSD 3-Clause "New" or "Revised" License
215 stars 46 forks source link

Connected_components_labeling instead of connected_components_labeling_box and _diamond #61

Open jni opened 3 years ago

jni commented 3 years ago

Currently, different versions of connected_components_labeling are spread out over different functions, e.g. connected_components_labeling_box. The API would be simpler if it were a single function with a connectivity parameter. Quoting @haesleinhuepf:

Box: 8- resp. 26-connected (3d/2d), partly separable Diamond: 4- resp. 6-connected, not separable

I engineered this terminology very carefully. And I'd love to know how to improve it.

And my response (only a month late 😅):

I prefer to use connected_components_labeling(binary, connectivity={1...ndim}) (see ndimage.label/ndimage.generate_binary_structure/skimage.measure.label). Separability is an implementation detail that you can handle internally (when connectivity==ndim).

jni commented 3 years ago

It might even be worth calling it just "label" to match the above-linked functions, but probably not — I always thought that name was not descriptive enough!

haesleinhuepf commented 3 years ago

@jni I like the idea! We could do this for all box/sphere filters, and have box as default (because it's faster). That would make things easier to read 🙂

Regarding naming: How about this scheme?

jni commented 3 years ago

Nice! Is label_spots this function? 😃

haesleinhuepf commented 3 years ago

Nice! Is label_spots this function? 😃

No, label_spots takes a binary image to label pixels. It assumes that only single isolated pixels are 1. It's a faster version of connected_component_labeling.

The method you look for is called pointlist_to_labelled_spots

Btw. discussions about optimal naming in the API are appreciated! 🙏