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?
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?
Copyright © 2021 Jogjafile Inc.
OpenCV is open source. You can look at the documentation and the source code.
You can choose 2 algorithms to perform connected component lablelling:
CCL_WU: Based on
CCL_GRANA: Based on
This works only for 8-connected components.
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
connectivityandccltype: