Skip to content

erode

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

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

imgproc_feature

example: samples/cpp/tutorial_code/ImgProc/Morphology_2.cpp Advanced morphology Transformations sample code Sample screenshot Check tutorial_opening_closing_hats "the corresponding tutorial" for more details Erodes an image by using a specific structuring element.

The function erodes the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the minimum is taken:

\texttt{dst} (x,y) =  \min _{(x',y'):  \, \texttt{kernel} (x',y') \ne0 } \texttt{src} (x+x',y+y')

The function supports the in-place mode. Erosion can be applied several ( iterations ) times. In case of multi-channel images, each channel is processed independently.

See: dilate, morphologyEx, getStructuringElement

erode(src: Mat, dst: Mat, kernel: Mat, anchor: Point, iterations: number, borderType: number, borderValue: Scalar): void;
5 available overloads
erode(src: Mat, dst: Mat, kernel: Mat): void;
erode(src: Mat, dst: Mat, kernel: Mat, anchor: Point): void;
erode(src: Mat, dst: Mat, kernel: Mat, anchor: Point, iterations: number): void;
erode(src: Mat, dst: Mat, kernel: Mat, anchor: Point, iterations: number, borderType: number): void;
erode(src: Mat, dst: Mat, kernel: Mat, anchor: Point, iterations: number, borderType: number, borderValue: Scalar): void;
src

input image; the number of channels can be arbitrary, but the depth should be one of CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.

dst

Output destination, filled by the native operation. output image of the same size and type as src.

kernel

structuring element used for erosion; if kernel=Mat(), a 3 x 3 rectangular structuring element is used. Kernel can be created using #getStructuringElement.

anchor

position of the anchor within the element; default value (-1, -1) means that the anchor is at the element center.

iterations

number of times erosion is applied.

borderType

pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported.

borderValue

border value in case of a constant border

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.