cv.connectedComponents - MATLAB File Help |
Computes the connected components labeled image of boolean image
[labels,N] = cv.connectedComponents(image)
[labels,N,stats,centroids] = cv.connectedComponents(image)
[...] = cv.connectedComponents(..., 'OptionName', optionValue, ...)
image
and
specified type in LType
. Labels are in the range [0, N-1]
where 0
represents the background label.int32
matrix. Statistics are accessed via stats(label, col)
where:
col=1
: The leftmost (x) coordinate which is the inclusive start of the
bounding box in the horizontal direction.col=2
: The topmost (y) coordinate which is the inclusive start of the
bounding box in the vertical direction.col=3
: The horizontal size of the bounding box (width).col=4
: The vertical size of the bounding box (height).col=5
: The total area (in pixels) of the connected component.(x,y)
output for
each label, including the background label. A Nx2 numeric matrix.
Centroids are accessed via centroids(label,:)
for x and y.int32
and uint16
are supported. default int32
The last two optional output arguments are only computed if requested.
This function uses parallel version of both Grana and Wu's algorithms (statistics included) if at least one allowed parallel framework is enabled and if the rows of the image are at least twice the number returned by cv.Utils.getNumberOfCPUs.
[Wu]:
"Two Strategies to Speed up Connected Components Algorithms", Kesheng Wu, et al (the SAUF (Scan array union find) variant using decision trees)
[Grana]:
"Optimized Block-based Connected Components Labeling with Decision Trees", Costantino Grana et al