Module imagingbook.common
Class ProjectiveMapping2D
java.lang.Object
imagingbook.common.geometry.mappings.linear.LinearMapping2D
imagingbook.common.geometry.mappings.linear.ProjectiveMapping2D
- Direct Known Subclasses:
AffineMapping2D
This class represents a projective transformation in 2D (also known as a "homography"). It can be specified uniquely by four pairs of corresponding points. It can be assumed that every instance of this class is indeed a projective mapping. See Secs. 21.1.4 and 21.3.1 of [1] for details.
[1] W. Burger, M.J. Burge, Digital Image Processing – An Algorithmic Introduction, 3rd ed, Springer (2022).
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionCreates the identity mapping.ProjectiveMapping2D
(double[][] A) Creates a projective mapping from a transformation matrix A, of arbitrary size.ProjectiveMapping2D
(double a00, double a01, double a02, double a10, double a11, double a12, double a20, double a21) Creates a projective mapping from the specified matrix elements.Creates a projective mapping from any linear mapping.Creates a projective mapping from an existing instance. -
Method Summary
Modifier and TypeMethodDescriptionConcatenates this mapping A with another linear mapping B and returns a new mapping C, such that C(x) = B(A(x)).Returns a copy of this mapping.static ProjectiveMapping2D
fromPoints
(Pnt2d[] P, Pnt2d[] Q) Creates a projective 2D mapping from two sequences of corresponding points.Calculates and returns the inverse mapping.double[][]
getJacobian
(Pnt2d xy) Returns the Jacobian matrix for this mapping, evaluated at the given 2D point.static void
For testing only.Methods inherited from class imagingbook.common.geometry.mappings.linear.LinearMapping2D
applyTo, concat, concatenate, getTransformationMatrix, normalize, toString
-
Constructor Details
-
ProjectiveMapping2D
public ProjectiveMapping2D()Creates the identity mapping. -
ProjectiveMapping2D
Creates a projective mapping from a transformation matrix A, of arbitrary size. All relevant elements of A are inserted into actual 3x3 transformation matrix, except element (2,2) which is ignored and always set to 1 (to keep the transformation projective). If A is larger than 3 x 3, the remaining elements are ignored.- Parameters:
A
- a transformation matrix of arbitrary size
-
ProjectiveMapping2D
public ProjectiveMapping2D(double a00, double a01, double a02, double a10, double a11, double a12, double a20, double a21) Creates a projective mapping from the specified matrix elements.- Parameters:
a00
- matrix element A_00a01
- matrix element A_01a02
- matrix element A_02a10
- matrix element A_10a11
- matrix element A_11a12
- matrix element A_12a20
- matrix element A_20a21
- matrix element A_21
-
ProjectiveMapping2D
Creates a projective mapping from any linear mapping. The transformation matrix gets normalized to a22 = 1.- Parameters:
m
- a linear mapping
-
ProjectiveMapping2D
Creates a projective mapping from an existing instance.- Parameters:
m
- a projective mapping
-
-
Method Details
-
fromPoints
Creates a projective 2D mapping from two sequences of corresponding points. If 4 point pairs are specified, the mapping is exact, otherwise a minimum least-squares fit is calculated.- Parameters:
P
- the source pointsQ
- the target points- Returns:
- a new projective mapping for the two point sets
-
concat
Concatenates this mapping A with another linear mapping B and returns a new mapping C, such that C(x) = B(A(x)).- Parameters:
B
- the second mapping- Returns:
- the concatenated mapping
-
duplicate
Returns a copy of this mapping.- Overrides:
duplicate
in classLinearMapping2D
- Returns:
- a new projective mapping
-
getInverse
Calculates and returns the inverse mapping. Note that the inverse A' of a projective transformation matrix A is again a linear transformation but its a'2' element is generally not 1. Scaling A' to A'' = A' / a22' yields a projective transformation that reverses A. While A * A' = I, the result of A * A'' is a scaled identity matrix.- Specified by:
getInverse
in interfaceInversion
- Overrides:
getInverse
in classLinearMapping2D
- Returns:
- the inverse projective transformation
-
getJacobian
Description copied from interface:Jacobian
Returns the Jacobian matrix for this mapping, evaluated at the given 2D point. See Appendix Sec. D.1.1 of [1] for more details.
[1] W. Burger, M.J. Burge, Digital Image Processing – An Algorithmic Introduction, 3rd ed, Springer (2022).
- Specified by:
getJacobian
in interfaceJacobian
- Parameters:
xy
- the 2D position to calculate the Jacobian for- Returns:
- the Jacobian matrix
-
main
For testing only.- Parameters:
args
- ignored
-