Skip to content

findTransformECCMultiScale

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

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

ARGUMENTSreference, sample, warpMatrix, eccParams
FUNCTIONfindTransformECCMultiScale
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]. Uses pyramids.

See: computeECC, estimateAffine2D, estimateAffinePartial2D, findHomography

findTransformECCMultiScale(reference: Mat, sample: Mat, warpMatrix: Mat, eccParams: ECCParameters, referenceMask: Mat, sampleMask: Mat): number;
4 available overloads
findTransformECCMultiScale(reference: Mat, sample: Mat, warpMatrix: Mat): number;
findTransformECCMultiScale(reference: Mat, sample: Mat, warpMatrix: Mat, eccParams: ECCParameters): number;
findTransformECCMultiScale(reference: Mat, sample: Mat, warpMatrix: Mat, eccParams: ECCParameters, referenceMask: Mat): number;
findTransformECCMultiScale(reference: Mat, sample: Mat, warpMatrix: Mat, eccParams: ECCParameters, referenceMask: Mat, sampleMask: Mat): number;
reference

Single channel reference image; CV_8U, CV_16U, CV_32F, CV_64F type.

sample

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

warpMatrix

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

eccParams

List of the algorithm parameters. See ECCParameters for details.

referenceMask

An optional single channel mask to indicate valid values of reference.

sampleMask

An optional single channel mask to indicate valid values of sample.

The function estimates the optimum transformation (warpMatrix) with respect to ECC criterion ([EP08]), that is

\texttt{warpMatrix} = \arg\max_{W} \texttt{ECC}(\texttt{templateImage}(x,y),\texttt{inputImage}(x',y'))

where

\begin{bmatrix} x' \\ y' \end{bmatrix} = W \cdot \begin{bmatrix} x \\ y \\ 1 \end{bmatrix}

(the equation holds with homogeneous coordinates for homography). It returns the final enhanced correlation coefficient, that is the correlation coefficient between the template image and the final warped input image. When a 3\times 3 matrix is given with motionType =0, 1 or 2, the third row is ignored.

Unlike findHomography and estimateRigidTransform, the function findTransformECCMultiScale implements an area-based alignment that builds on intensity similarities. In essence, the function updates the initial transformation that roughly aligns the images. If this information is missing, the identity warp (unity matrix) is used as an initialization. Note that if images undergo strong displacements/rotations, an initial transformation that roughly aligns the images is necessary (e.g., a simple euclidean/similarity transform that allows for the images showing the same image content approximately). Use inverse warping in the second image to take an image close to the first one, i.e. use the flag WARP_INVERSE_MAP with warpAffine or warpPerspective. See also the OpenCV sample image_alignment.cpp that demonstrates the use of the function. Note that the function throws an exception if algorithm does not converges. Unlike findTransformECC, the findTransformECCMultiScale uses pyramids, making function more stable and able to handle correctly more sophisticated cases.

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.