DanielPlayne / playne-equivalence-algorithm

MIT License
20 stars 2 forks source link

Labeling of binary zeros #2

Closed elheck closed 3 years ago

elheck commented 3 years ago

Hi Daniel, Your algorithm works on a binary image, so I would assume values to be either 0(background) or 1(foreground). In the referenced init_labels you are looking for the connectivity of every pixel , 0s as well. Wouldn't that just form one or more clusters of pure background? So my question is, why is 0 as a pixel value not excluded? And wouldn't that save computation?

https://github.com/DanielPlayne/playne-equivalence-algorithm/blob/11749cf0c7f768279db8ebecb49895543c5c29ff/playne_equivalence_direct_2D_clamp.cu#L153

DanielPlayne commented 3 years ago

Hi elheck,

If you have an application where background (0) pixels are not considered important then yes you could just ignore any of these pixels and it would save you some computation.

You can also use this algorithm for images with multiple values (not just binary) where equality (or any transitive relation) determines the connectivity rather than just binary images (I stuck to binary to make my test cases consistent).

For some applications (such as statistical mechanics), the binary image doesn't represent background/foreground pixels and labelling both states is equally important which is why I included it in my reference code.

Hope that helps

elheck commented 3 years ago

Hi Daniel, Thank you for your answer, I saw that you are using binary images and all I could think about was background and foreground. I didn't think about other applications where all values are important.

Thanks again that helped me a lot, elheck