Skip to contents

findTransformECC computes the geometric transform between two images in terms of the Enhanced Correlation Coefficient criterion.

Usage

findTransformECC(
  template,
  image,
  warp_matrix = NULL,
  warp_mode = "affine",
  max_it = 200,
  epsilon = 0.001,
  mask = NULL,
  filt_size = 0
)

Arguments

template

A grayscale Image object.

image

A grayscale Image object of the same dimensions as template.

warp_matrix

An initial mapping (warp) matrix. It must be a 3x3 matrix when warp_mode is set to "homography", a 2x3 matrix otherwise. If set to NULL (the default), it will be automatically initialized as an identity matrix with the appropriate dimensions.

warp_mode

A character string indicating the type of warping required to transform image into template. It can be any of the following:

"translation":

simple translational transformation.

"euclidean":

Euclidean (rigid) transformation (translation + rotation).

"affine" (default):

affine transformation (Euclidean + shear; this transformation will preserve parallelism between lines).

"homography":

homography transformation (affine + perspective; this transformation does not preserve parallelism between lines).

max_it

The maximum number of iterations (default: 200).

epsilon

The convergene tolerance (default: 1e-3).

mask

A binary Image object of the same dimensions as template. Only the pixels of image where mask is nonzero are used in the computation. If NULL, all pixels are used.

filt_size

The size in pixels of a gaussian blur filter applied to the images before computation of the transform. When set to 0 (the default), no filtering is applied.

Value

A 2x3 or 3x3 (if warp_mode = "homography") matrix.

References

Evangelidis, G. D., and Psarakis, E. Z. (2008). Parametric image alignment using enhanced correlation coefficient maximization. IEEE Trans. Pattern Anal. Mach. Intell. 30, 1858–1865. doi:10.1109/TPAMI.2008.113.

Author

Simon Garnier, garnier@njit.edu

Examples

file1 <- system.file("sample_img/balloon1.png", package = "Rvision")
file2 <- system.file("sample_img/balloon2.png", package = "Rvision")
balloon1 <- changeColorSpace(image(file1), "GRAY")
balloon2 <- changeColorSpace(image(file2), "GRAY")
findTransformECC(balloon1, balloon2)
#>            [,1]     [,2]      [,3]
#> [1,]  1.0909468 0.128925 -67.90497
#> [2,] -0.1418501 1.148562  17.78894