Table of Contents

Method ConnectedComponentsWithStatsWithAlgorithm

Namespace
OpenCvSharp
Assembly
OpenCvSharp.dll

ConnectedComponentsWithStatsWithAlgorithm(InputArray, OutputArray, OutputArray, OutputArray, PixelConnectivity, MatType, ConnectedComponentsAlgorithmsTypes)

computes the connected components labeled image of boolean image and also produces a statistics output for each label.

image with 4 or 8 way connectivity - returns N, the total number of labels[0, N - 1] where 0 represents the background label.ltype specifies the output label image type, an important consideration based on the total number of labels or alternatively the total number of pixels in the source image.ccltype specifies the connected components labeling algorithm to use, currently Grana's (BBDT) and Wu's (SAUF) algorithms are supported, see the #ConnectedComponentsAlgorithmsTypes for details.Note that SAUF algorithm forces a row major ordering of labels while BBDT does not. 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 #getNumberOfCPUs.

public static int ConnectedComponentsWithStatsWithAlgorithm(InputArray image, OutputArray labels, OutputArray stats, OutputArray centroids, PixelConnectivity connectivity, MatType ltype, ConnectedComponentsAlgorithmsTypes ccltype)

Parameters

image InputArray

the 8-bit single-channel image to be labeled

labels OutputArray

destination labeled image

stats OutputArray

statistics output for each label, including the background label, see below for available statistics.Statistics are accessed via stats(label, COLUMN) where COLUMN is one of #ConnectedComponentsTypes. The data type is CV_32S.

centroids OutputArray

centroid output for each label, including the background label. Centroids are accessed via centroids(label, 0) for x and centroids(label, 1) for y.The data type CV_64F.

connectivity PixelConnectivity

8 or 4 for 8-way or 4-way connectivity respectively

ltype MatType

output image label type. Currently CV_32S and CV_16U are supported.

ccltype ConnectedComponentsAlgorithmsTypes

connected components algorithm type.

Returns

int