Skip to content

connectedComponentsWithStatsWithAlgorithm

Image processingfunctionOpenCV 5.0.0
import { connectedComponentsWithStatsWithAlgorithm } from '@banou/opencv-wasm'

Use after await initOpenCV(). See the initialization and named imports guide.

ARGUMENTSimage, labels, stats, centroids
FUNCTIONconnectedComponentsWithStatsWithAlgorithm
RETURN TYPEnumber
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

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 Bolelli (Spaghetti) [Bolelli2019], Grana (BBDT) [Grana2010] and Wu's (SAUF) [Wu2009] algorithms are supported, see the #ConnectedComponentsAlgorithmsTypes for details. Note that SAUF algorithm forces a row major ordering of labels while Spaghetti and BBDT do not. This function uses parallel version of the 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.

connectedComponentsWithStatsWithAlgorithm(image: Mat, labels: Mat, stats: Mat, centroids: Mat, connectivity: number, ltype: number, ccltype: number): number;
image

the 8-bit single-channel image to be labeled

labels

Output destination, filled by the native operation. destination labeled image

stats

Output destination, filled by the native operation. statistics output for each label, including the background label. Statistics are accessed via stats(label, COLUMN) where COLUMN is one of #ConnectedComponentsTypes, selecting the statistic. The data type is CV_32S.

centroids

Output destination, filled by the native operation. 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

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

ltype

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

ccltype

connected components algorithm type (see #ConnectedComponentsAlgorithmsTypes).

Returns

The number result.

These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.