Skip to content

findTransformECCWithMask

Motion and trackingfunctionOpenCV 5.0.0
import { findTransformECCWithMask } from '@banou/opencv-wasm'

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

ARGUMENTStemplateImage, inputImage, templateMask, inputMask
FUNCTIONfindTransformECCWithMask
RETURN TYPEnumber
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

Finds the geometric transform (warp) between two images in terms of the ECC criterion [EP08] using validity masks for both the template and the input images.

This function extends findTransformECC() by adding a mask for the template image. The Enhanced Correlation Coefficient is evaluated only over pixels that are valid in both images: on each iteration inputMask is warped into the template frame and combined with templateMask, and only the intersection of these masks contributes to the objective function.

See: findTransformECC, computeECC, estimateAffine2D, estimateAffinePartial2D, findHomography

findTransformECCWithMask(templateImage: Mat, inputImage: Mat, templateMask: Mat, inputMask: Mat, warpMatrix: Mat, motionType: number, criteria: TermCriteria, gaussFiltSize: number): number;
4 available overloads
findTransformECCWithMask(templateImage: Mat, inputImage: Mat, templateMask: Mat, inputMask: Mat, warpMatrix: Mat): number;
findTransformECCWithMask(templateImage: Mat, inputImage: Mat, templateMask: Mat, inputMask: Mat, warpMatrix: Mat, motionType: number): number;
findTransformECCWithMask(templateImage: Mat, inputImage: Mat, templateMask: Mat, inputMask: Mat, warpMatrix: Mat, motionType: number, criteria: TermCriteria): number;
findTransformECCWithMask(templateImage: Mat, inputImage: Mat, templateMask: Mat, inputMask: Mat, warpMatrix: Mat, motionType: number, criteria: TermCriteria, gaussFiltSize: number): number;
templateImage

1 or 3 channel template image; CV_8U, CV_16U, CV_32F, CV_64F type.

inputImage

input image which should be warped with the final warpMatrix in order to provide an image similar to templateImage, same type as templateImage.

templateMask

single-channel 8-bit mask for templateImage indicating valid pixels to be used in the alignment. Must have the same size as templateImage.

inputMask

single-channel 8-bit mask for inputImage indicating valid pixels before warping. Must have the same size as inputImage.

warpMatrix

Input/output value, modified by the native operation. floating-point 2\times 3 or 3\times 3 mapping matrix (warp).

motionType

parameter, specifying the type of motion:

  • MOTION_TRANSLATION sets a translational motion model; warpMatrix is 2\times 3 with the first 2\times 2 part being the unity matrix and the rest two parameters being estimated.
  • MOTION_EUCLIDEAN sets a Euclidean (rigid) transformation as motion model; three parameters are estimated; warpMatrix is 2\times 3.
  • MOTION_AFFINE sets an affine motion model (DEFAULT); six parameters are estimated; warpMatrix is 2\times 3.
  • MOTION_HOMOGRAPHY sets a homography as a motion model; eight parameters are estimated; warpMatrix is 3\times 3.
criteria

parameter, specifying the termination criteria of the ECC algorithm; criteria.epsilon defines the threshold of the increment in the correlation coefficient between two iterations (a negative criteria.epsilon makes criteria.maxcount the only termination criterion). Default values are shown in the declaration above.

gaussFiltSize

size of the Gaussian blur filter used for smoothing images and masks before computing the alignment (DEFAULT: 5).

Returns

The number result.

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.