1
votes

In OpenCV 3.0 there is a function called connectedComponent.

I know that it takes as input a binary image and returns the labels and the number of connected components, but what algorithm is used internally?

2
@Miki In the opencv 3.0 there is a function called connectedComponent and I want know how is made and how works. I know that it takes in input binary image label image which is returned and the connectivity and return the number of connected components, but because I am having to write a report I need to know how it works. Thanks - user7209199
Could you try and expand your question. I am particularly confused by "if someone like it was realized the connectedComponent function provided by the library". If you can spot an obvious typo in that, fantastic! If not, you could try and repeat that in other words? Either way, edit your question to fix the problem. - Martin Bonner supports Monica
Right. I posted my comment while you were posting yours. As I said: please edit the question to include that information. - Martin Bonner supports Monica
@MartinBonner you understand my comment? - user7209199
The comment is much better. Tip: When communicating in a foreign language, prefer to say too much rather than too little, and repeat yourself - it gives other people more chance to guess what you mean. (Learnt while communicating in German with colleagues.) - Martin Bonner supports Monica

2 Answers

5
votes

OpenCV is open source. You can look at the documentation and the source code.

You can choose 2 algorithms to perform connected component lablelling:

The default in OpenCV >= 3.2 (CCL_DEFAULT) uses Wu's algorithm for 4-connectivity, and Grana's algorithm for 8 connectivity.

In OpenCV 3.0.0 you use Wu's algorithm for both 4 and 8 connectivity, while in OpenCV >= 3.2 you can choose one of the 3 options, according to the fields connectivity and ccltype:

       \  connectivity   4    |   8
        \                     |
type     \                    |
                              |
CCL_DEFAULT              Wu   |  Grana
CCL_WU                   Wu   |  Wu
CCL_GRANA                Wu   |  Grana
1
votes

You can read about connected component labeling algorithms in numerous sources

OpenCV implementation is here and contains this clue:

 //Based on "Two Strategies to Speed up Connected Components Algorithms", 
 //the SAUF (Scan array union find) variant
 //using decision trees
 //Kesheng Wu, et al

Article