Skip to content

warpAffine

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

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

Applies an affine transformation to an image.

The function warpAffine transforms the source image using the specified matrix:

\texttt{dst} (x,y) =  \texttt{src} ( \texttt{M} _{11} x +  \texttt{M} _{12} y +  \texttt{M} _{13}, \texttt{M} _{21} x +  \texttt{M} _{22} y +  \texttt{M} _{23})

when the flag #WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted with #invertAffineTransform and then put in the formula above instead of M. The function cannot operate in-place.

See: warpPerspective, resize, remap, getRectSubPix, transform

warpAffine(src: Mat, dst: Mat, M: Mat, dsize: Size, flags: number, borderMode: number, borderValue: Scalar, hint: number): void;
5 available overloads
warpAffine(src: Mat, dst: Mat, M: Mat, dsize: Size): void;
warpAffine(src: Mat, dst: Mat, M: Mat, dsize: Size, flags: number): void;
warpAffine(src: Mat, dst: Mat, M: Mat, dsize: Size, flags: number, borderMode: number): void;
warpAffine(src: Mat, dst: Mat, M: Mat, dsize: Size, flags: number, borderMode: number, borderValue: Scalar): void;
warpAffine(src: Mat, dst: Mat, M: Mat, dsize: Size, flags: number, borderMode: number, borderValue: Scalar, hint: number): void;
src

input image.

dst

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

M

2\times 3 transformation matrix.

dsize

size of the output image.

flags

combination of interpolation methods (see #InterpolationFlags) and the optional flag #WARP_INVERSE_MAP that means that M is the inverse transformation ( \texttt{dst}\rightarrow\texttt{src} ).

borderMode

pixel extrapolation method (see #BorderTypes); when borderMode=#BORDER_TRANSPARENT, it means that the pixels in the destination image corresponding to the "outliers" in the source image are not modified by the function.

borderValue

value used in case of a constant border; by default, it is 0.

hint

Implementation modification flags. Set #ALGO_HINT_APPROX to use FP16 precision (if available) for linear calculation for faster speed. See #AlgorithmHint.

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.