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
367 stars 43 forks source link

6-connected for DNS #25

Closed hannahmenke closed 5 years ago

hannahmenke commented 5 years ago

Is it possible to calculate 6-connectivity, or 18 instead of 26? A bit of a departure from brain imaging, but this feature would be very useful for finite volume solvers.

william-silversmith commented 5 years ago

This is a cool use case! I'm not really familiar with these types of analyses, is this the kind of thing you're talking about? https://www3.nd.edu/~gtryggva/MultiphaseDNS/DNS-Solver.pdf

It should be pretty easy to make this. The 6-connected version is simple, and the 18-connected logic is derivative of the 26-connected version.

hannahmenke commented 5 years ago

Yep, that's the idea. The 6-connected output would be very useful for generating the different labels needed for input into each phase since the solvers only compute transport over voxel faces.

william-silversmith commented 5 years ago

Okay! Version 1.4.0 is released with support for 26, 18, and 6 connectivities. I also sped up the region adjacency graph and added 26, 18, and 6 connectivity support for it. You can use it like so:

import cc3d

cc_labels = cc3d.connected_components(labels, connectivity=18)

G = cc3d.region_graph(cc_labels, connectivity=18)

Happy sciencing :)