Skip to content

ximgproc_SuperpixelSLIC

Extended image processingclassOpenCV 5.0.0
import { ximgproc_SuperpixelSLIC } from '@banou/opencv-wasm'

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

Native object: release it with using or delete(). Factories can return null; check before calling methods. Inherits Algorithm.

Class implementing the SLIC (Simple Linear Iterative Clustering) superpixels algorithm described in [Achanta2012].

SLIC (Simple Linear Iterative Clustering) clusters pixels using pixel channels and image plane space to efficiently generate compact, nearly uniform superpixels. The simplicity of approach makes it extremely easy to use a lone parameter specifies the number of superpixels and the efficiency of the algorithm makes it very practical. Several optimizations are available for SLIC class: SLICO stands for "Zero parameter SLIC" and it is an optimization of baseline SLIC described in [Achanta2012]. MSLIC stands for "Manifold SLIC" and it is an optimization of baseline SLIC described in [Liu_2017_IEEE].

Constructors and members

clone

Create another handle to the same native object. This retains the object without copying its pixels or algorithm state; dispose both handles separately.

clone(): this;
Returns

The this result.

getNumberOfSuperpixels

Calculates the actual amount of superpixels on a given segmentation computed and stored in SuperpixelSLIC object.

getNumberOfSuperpixels(): number;
Returns

The number result.

iterate

Calculates the superpixel segmentation on a given image with the initialized parameters in the SuperpixelSLIC object.

This function can be called again without the need of initializing the algorithm with
createSuperpixelSLIC(). This save the computational cost of allocating memory for all the
structures of the algorithm.
iterate(num_iterations: number): void;
2 available overloads
iterate(): void;
iterate(num_iterations: number): void;
num_iterations

Number of iterations. Higher number improves the result.

The function computes the superpixels segmentation of an image with the parameters initialized with the function createSuperpixelSLIC(). The algorithms starts from a grid of superpixels and then refines the boundaries by proposing updates of edges boundaries.

getLabels

Returns the segmentation labeling of the image.

Each label represents a superpixel, and each pixel is assigned to one superpixel label.
getLabels(labels_out: Mat): void;
labels_out

Output destination, filled by the native operation. Return: A CV_32SC1 integer array containing the labels of the superpixel segmentation. The labels are in the range [0, getNumberOfSuperpixels()].

The function returns an image with the labels of the superpixel segmentation. The labels are in the range [0, getNumberOfSuperpixels()].

getLabelContourMask

Returns the mask of the superpixel segmentation stored in SuperpixelSLIC object.

getLabelContourMask(image: Mat, thick_line: boolean): void;
2 available overloads
getLabelContourMask(image: Mat): void;
getLabelContourMask(image: Mat, thick_line: boolean): void;
image

Output destination, filled by the native operation. Return: CV_8U1 image mask where -1 indicates that the pixel is a superpixel border, and 0 otherwise.

thick_line

If false, the border is only one pixel wide, otherwise all pixels at the border are masked.

The function return the boundaries of the superpixel segmentation.

enforceLabelConnectivity

Enforce label connectivity.

enforceLabelConnectivity(min_element_size: number): void;
2 available overloads
enforceLabelConnectivity(): void;
enforceLabelConnectivity(min_element_size: number): void;
min_element_size

The minimum element size in percents that should be absorbed into a bigger superpixel. Given resulted average superpixel size valid value should be in 0-100 range, 25 means that less then a quarter sized superpixel should be absorbed, this is default.

The function merge component that is too small, assigning the previously found adjacent label to this component. Calling this function may change the final number of superpixels.

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.