filter2Dp
import { filter2Dp } from '@banou/opencv-wasm'Use after await initOpenCV(). See the initialization and named imports guide.
Convolves an image with the kernel.
The function applies an arbitrary linear filter to an image. In-place operation is supported. 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).
The function uses the DFT-based algorithm in case of sufficiently large kernels (~`11 x 11` or larger) and the direct algorithm for small kernels.
See: sepFilter2D, dft, matchTemplate
filter2Dp(src: Mat, dst: Mat, kernel: Mat, params: Filter2DParams): void;2 available overloads
filter2Dp(src: Mat, dst: Mat, kernel: Mat): void;filter2Dp(src: Mat, dst: Mat, kernel: Mat, params: Filter2DParams): void;srcinput image.
dstOutput destination, filled by the native operation. output image of the same size and the same number of channels as src.
kernelconvolution 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.
paramsparams argument (Filter2DParams).
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.