connectedComponentsWithStats
import { connectedComponentsWithStats } from '@banou/opencv-wasm'Use after await initOpenCV(). See the initialization and named imports guide.
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.
connectedComponentsWithStats(image: Mat, labels: Mat, stats: Mat, centroids: Mat, connectivity: number, ltype: number): number;3 available overloads
connectedComponentsWithStats(image: Mat, labels: Mat, stats: Mat, centroids: Mat): number;connectedComponentsWithStats(image: Mat, labels: Mat, stats: Mat, centroids: Mat, connectivity: number): number;connectedComponentsWithStats(image: Mat, labels: Mat, stats: Mat, centroids: Mat, connectivity: number, ltype: number): number;imagethe 8-bit single-channel image to be labeled
labelsOutput destination, filled by the native operation. destination labeled image
statsOutput 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.
centroidsOutput 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.
connectivity8 or 4 for 8-way or 4-way connectivity respectively
ltypeoutput image label type. Currently CV_32S and CV_16U are supported.
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.