Skip to content

getDerivKernels

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

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

Returns filter coefficients for computing spatial image derivatives.

The function computes and returns the filter coefficients for spatial image derivatives. When ksize=FILTER_SCHARR, the Scharr 3 \times 3 kernels are generated (see #Scharr). Otherwise, Sobel kernels are generated (see #Sobel). The filters are normally passed to #sepFilter2D or to

getDerivKernels(kx: Mat, ky: Mat, dx: number, dy: number, ksize: number, normalize: boolean, ktype: number): void;
3 available overloads
getDerivKernels(kx: Mat, ky: Mat, dx: number, dy: number, ksize: number): void;
getDerivKernels(kx: Mat, ky: Mat, dx: number, dy: number, ksize: number, normalize: boolean): void;
getDerivKernels(kx: Mat, ky: Mat, dx: number, dy: number, ksize: number, normalize: boolean, ktype: number): void;
kx

Output destination, filled by the native operation. Output matrix of row filter coefficients. It has the type ktype .

ky

Output destination, filled by the native operation. Output matrix of column filter coefficients. It has the type ktype .

dx

Derivative order in respect of x.

dy

Derivative order in respect of y.

ksize

Aperture size. It can be FILTER_SCHARR, 1, 3, 5, or 7.

normalize

Flag indicating whether to normalize (scale down) the filter coefficients or not. Theoretically, the coefficients should have the denominator =2^{ksize*2-dx-dy-2}. If you are going to filter floating-point images, you are likely to use the normalized kernels. But if you compute derivatives of an 8-bit image, store the results in a 16-bit image, and wish to preserve all the fractional bits, you may want to set normalize=false .

ktype

Type of filter coefficients. It can be CV_32f or CV_64F .

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.