Skip to content

gapi_filter2D

gapifunctionOpenCV 5.0.0
import { gapi_filter2D } from '@banou/opencv-wasm'

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

ARGUMENTSsrc, ddepth, kernel, anchor
FUNCTIONgapi_filter2D
RETURN TYPEGMat
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

Convolves an image with the kernel.

The function applies an arbitrary linear filter to an image. When the aperture is partially outside the image, the function interpolates outlier pixel values according to the specified border mode.

The function does actually compute correlation, not the convolution:

\texttt{dst} (x,y) =  \sum _{ \substack{0\leq x' < \texttt{kernel.cols}\\{0\leq y' < \texttt{kernel.rows}}}}  \texttt{kernel} (x',y')* \texttt{src} (x+x'- \texttt{anchor.x} ,y+y'- \texttt{anchor.y} )

That is, the kernel is not mirrored around the anchor point. If you need a real convolution, flip the kernel using flip and set the new anchor to (kernel.cols - anchor.x - 1, kernel.rows - anchor.y - 1).

Supported matrix data types are CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1. Output image must have the same size and number of channels an input image.

Note: - Rounding to nearest even is procedeed if hardware supports it, if not - to nearest.

  • Function textual ID is "org.opencv.imgproc.filters.filter2D"

See: sepFilter

gapi_filter2D(src: GMat, ddepth: number, kernel: Mat, anchor: Point, delta: Scalar, borderType: number, borderValue: Scalar): GMat;
5 available overloads
gapi_filter2D(src: GMat, ddepth: number, kernel: Mat): GMat;
gapi_filter2D(src: GMat, ddepth: number, kernel: Mat, anchor: Point): GMat;
gapi_filter2D(src: GMat, ddepth: number, kernel: Mat, anchor: Point, delta: Scalar): GMat;
gapi_filter2D(src: GMat, ddepth: number, kernel: Mat, anchor: Point, delta: Scalar, borderType: number): GMat;
gapi_filter2D(src: GMat, ddepth: number, kernel: Mat, anchor: Point, delta: Scalar, borderType: number, borderValue: Scalar): GMat;
src

input image.

ddepth

desired depth of the destination image

kernel

convolution kernel (or rather a correlation kernel), a single-channel floating point matrix; if you want to apply different kernels to different channels, split the image into separate color planes using split and process them individually.

anchor

anchor of the kernel that indicates the relative position of a filtered point within the kernel; the anchor should lie within the kernel; default value (-1,-1) means that the anchor is at the kernel center.

delta

optional value added to the filtered pixels before storing them in dst.

borderType

pixel extrapolation method, see cv::BorderTypes

borderValue

border value in case of constant border type

Returns

The GMat result. Release returned native handles with using or delete(), including handles nested in results.

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.