seung-lab / connected-components-3d

Connected components on discrete and continuous multilabel 3D & 2D images. Handles 26, 18, and 6 connected variants; periodic boundaries (4, 8, & 6)
GNU Lesser General Public License v3.0
356 stars 42 forks source link

voxel_connectivity_graph and contacts can not be applied in 2D label #95

Closed 1999kevin closed 2 years ago

1999kevin commented 2 years ago

Nice job!. I want to find the neighborhood of each label in 2D segmentation and I think it is the function of contacts. However, I find that these functions could not be applied to 2D segmentation and report "TypeError: No matching signature found".

Could you please help you to fix this bug?

1999kevin commented 2 years ago

Solve it by expanding 2D to 3D by adding one axis

william-silversmith commented 2 years ago

I wasn't sure if anyone was going to use voxel connectivity graph in 3d let alone 2d. I'm glad you found it helpful! It was made for a very specific purpose I had in mind (and still have yet to do). I'll consider fixing it up in 2D.

william-silversmith commented 2 years ago

~Can you share an example of the code that broke?~ Nevermind, I think voxel_connectivity_graph should work, but I can see why contacts and region_graph are breaking in 2D.

1999kevin commented 2 years ago

~Can you share an example of the code that broke?~ Nevermind, I think voxel_connectivity_graph should work, but I can see why contacts and region_graph are breaking in 2D.

Thank you for your reply. A 2D input array with dimension (h,w) can produce such a bug. However, I make contactswork by expanding one axis using such a command: a = np.expand_dims(a, axis=2).

I develop an greedy algorigm to convert a segmentation map with a lot of labels to a map with specific number of labels, and I find your contacts is useful to find the neighbor for each label

william-silversmith commented 2 years ago

The new version of cc3d should have this fixed. Let me know if you need more help!