connectedComponentsWithAlgorithm
import { connectedComponentsWithAlgorithm } from '@banou/opencv-wasm'Use after await initOpenCV(). See the initialization and named imports guide.
example: samples/cpp/connected_components.cpp This program demonstrates connected components and use of the trackbar computes the connected components labeled image of boolean image
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 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.
connectedComponentsWithAlgorithm(image: Mat, labels: Mat, connectivity: number, ltype: number, ccltype: number): number;imagethe 8-bit single-channel image to be labeled
labelsOutput destination, filled by the native operation. destination labeled image
connectivity8 or 4 for 8-way or 4-way connectivity respectively
ltypeoutput image label type. Currently CV_32S and CV_16U are supported.
ccltypeconnected components algorithm type (see the #ConnectedComponentsAlgorithmsTypes).
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.