java.lang.Object
imagingbook.common.geometry.fitting.points.ProcrustesFit2d
- All Implemented Interfaces:
LinearFit2d
Implements a 2-dimensional Procrustes fit, using the algorithm described in [1]. Usage example:
Point[] P = ... // create sequence of 2D source points Point[] Q = ... // create sequence of 2D target points ProcrustesFit pf = new ProcrustesFit(P, Q); RealMatrix R = pf.getRotation(); RealVector t = pf.getTranslation(); double s = pf.getScale(); double err = pf.getError(); RealMatrix A = pf.getTransformationMatrix();
[1] Shinji Umeyama, "Least-squares estimation of transformation parameters between two point patterns", IEEE Transactions on Pattern Analysis and Machine Intelligence, 13.4 (Apr. 1991), pp. 376–380.
- Version:
- 2021/11/27
-
Constructor Summary
ConstructorsConstructorDescriptionProcrustesFit2d
(Pnt2d[] P, Pnt2d[] Q) Convenience constructor, with parametersallowTranslation
,allowScaling
andforceRotation
set totrue
.ProcrustesFit2d
(Pnt2d[] P, Pnt2d[] Q, boolean allowTranslation, boolean allowScaling, boolean forceRotation) Full constructor. -
Method Summary
Modifier and TypeMethodDescriptiondouble
getError()
Returns the total error for this fit.double[][]
Retrieves the estimated orthogonal (rotation) matrix.double
getScale()
Retrieves the estimated scale.double[][]
Returns the (3,3) or (2,3) transformation matrix A for this fit, such thaty_i ~ A * x_i
(withx_i
in homogeneous coordinates).double[]
Retrieves the estimated translation vector.
-
Constructor Details
-
ProcrustesFit2d
Convenience constructor, with parametersallowTranslation
,allowScaling
andforceRotation
set totrue
.- Parameters:
P
- the source pointsQ
- the target points
-
ProcrustesFit2d
public ProcrustesFit2d(Pnt2d[] P, Pnt2d[] Q, boolean allowTranslation, boolean allowScaling, boolean forceRotation) Full constructor.- Parameters:
P
- the first point sequenceQ
- the second point sequenceallowTranslation
- iftrue
, translation (t) between point sets is considered, otherwise zero translation is assumedallowScaling
- iftrue
, scaling (s) between point sets is considered, otherwise unit scale assumedforceRotation
- iftrue
, the orthogonal part of the transformation (Q) is forced to a true rotation and no reflection is allowed
-
-
Method Details
-
getScale
Retrieves the estimated scale.- Returns:
- The estimated scale (or 1 if
allowscaling = false
).
-
getRotation
Retrieves the estimated orthogonal (rotation) matrix.- Returns:
- The estimated rotation matrix.
-
getTranslation
Retrieves the estimated translation vector.- Returns:
- The estimated translation vector.
-
getTransformationMatrix
Description copied from interface:LinearFit2d
Returns the (3,3) or (2,3) transformation matrix A for this fit, such thaty_i ~ A * x_i
(withx_i
in homogeneous coordinates).- Specified by:
getTransformationMatrix
in interfaceLinearFit2d
- Returns:
- the transformation matrix for this fit
-
getError
Description copied from interface:LinearFit2d
Returns the total error for this fit.- Specified by:
getError
in interfaceLinearFit2d
- Returns:
- the fitting error
-