0

I would like to find the connected components in this image (the image is binary)

enter image description here

and for that, I use the OpenCV cv2.connectedComponentsWithStats algorithm. But the latter gives me a result that I can't understand. Indeed, if we take the first connected component, we find that there are several parts of this component that are not connected (see image, the component is in white).

enter image description here

Could you explain to me the logic behind this result?

PS 1: I tried with other connected component algorithms (such as skimage.mesure.label) and I got the same results!

PS 2: For comparaison, here's the second connected component (always in white)

enter image description here

schlodinger
  • 537
  • 3
  • 14
  • 1
    Hoe are you showing the connected components? You get back a labeled image, where pixels for the fist connected component have a value of 1, those of the second a value of 2, etc. Pixels with a value of 0 are not part of a connected component, they are background pixels, the pixels with a value of 0 in the input. Only foreground pixels are considered by connected component analysis. – Cris Luengo Nov 11 '19 at 14:14
  • @CrisLuengo Thanks for your answer, this explain everything, and this is what I have noticed! – schlodinger Nov 11 '19 at 14:32

0 Answers0