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

Is the output label of largest_k ordered? #118

Closed hhuang91 closed 5 months ago

hhuang91 commented 5 months ago

Hi,

I'm wondering if the output label of largest_k is ordered?

For example, if I have labels_out = cc3d.largest_k(labels_in, k=3, connectivity=6) Does that mean (labels_out==3).sum() > (labels_out==2).sum() > (labels_out==1).sum() , or (labels_out==3).sum() < (labels_out==2).sum() < (labels_out==1).sum() , or there is no particular order?

I'm asking because I have seen cases where larger label has larger number of components, but also cases where larger number has very small number of components, sometime even 1.

Thank you!

william-silversmith commented 5 months ago

Hi! No, there is no particular ordering on the output label. There may be some loose spatial ordering to it, but it's the result of the output of union-find and a renumbering scan over the volume.

hhuang91 commented 5 months ago

Thank you for the clarification!