Calculate an affine transformation matrix from two sets of landmarks. Source is the item that is transformed to align to target. The The generated affine transformation matrix is the affine transform that defines this transformation.

calculateAffineMatrixFromLandmarks(source, target)

Arguments

source, target

matrix or data.frame-like. Source and target landmarks provided as paired x (first) y (second) columns.

Value

a 3x3 matrix that defines an affine transform

See also

Examples

m1 <- matrix(c(
        4211.476, 4925.052,
        5906.339, 4251.025,
        4830.097, 3342.676,
        5954.410, 3393.603
    ),
    4, 2, byrow = TRUE
)

m2 <- matrix(c(
        7218.570, -11999.111,
        8647.143, -15008.278,
        10150.203, -12953.273,
        10172.141, -15008.059
    ),
    4, 2, byrow = TRUE
)
calculateAffineMatrixFromLandmarks(m1, m2)
#>            [,1]       [,2]      [,3]
#> [1,]  0.1188965 -1.7979378 15578.068
#> [2,] -1.8195643 -0.1068888 -3808.687
#> [3,]  0.0000000  0.0000000     1.000