Class ProcrustesFit2d

java.lang.Object
imagingbook.common.geometry.fitting.points.ProcrustesFit2d
All Implemented Interfaces:
LinearFit2d

public class ProcrustesFit2d extends Object implements 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

    Constructors
    Constructor
    Description
    Convenience constructor, with parameters allowTranslation, allowScaling and forceRotation set to true.
    ProcrustesFit2d(Pnt2d[] P, Pnt2d[] Q, boolean allowTranslation, boolean allowScaling, boolean forceRotation)
    Full constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Returns the total error for this fit.
    double[][]
    Retrieves the estimated orthogonal (rotation) matrix.
    double
    Retrieves the estimated scale.
    double[][]
    Returns the (3,3) or (2,3) transformation matrix A for this fit, such that y_i ~ A * x_i (with x_i in homogeneous coordinates).
    double[]
    Retrieves the estimated translation vector.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ProcrustesFit2d

      public ProcrustesFit2d(Pnt2d[] P, Pnt2d[] Q)
      Convenience constructor, with parameters allowTranslation, allowScaling and forceRotation set to true.
      Parameters:
      P - the source points
      Q - the target points
    • ProcrustesFit2d

      public ProcrustesFit2d(Pnt2d[] P, Pnt2d[] Q, boolean allowTranslation, boolean allowScaling, boolean forceRotation)
      Full constructor.
      Parameters:
      P - the first point sequence
      Q - the second point sequence
      allowTranslation - if true, translation (t) between point sets is considered, otherwise zero translation is assumed
      allowScaling - if true, scaling (s) between point sets is considered, otherwise unit scale assumed
      forceRotation - if true, the orthogonal part of the transformation (Q) is forced to a true rotation and no reflection is allowed
  • Method Details

    • getScale

      public double getScale()
      Retrieves the estimated scale.
      Returns:
      The estimated scale (or 1 if allowscaling = false).
    • getRotation

      public double[][] getRotation()
      Retrieves the estimated orthogonal (rotation) matrix.
      Returns:
      The estimated rotation matrix.
    • getTranslation

      public double[] getTranslation()
      Retrieves the estimated translation vector.
      Returns:
      The estimated translation vector.
    • getTransformationMatrix

      public double[][] getTransformationMatrix()
      Description copied from interface: LinearFit2d
      Returns the (3,3) or (2,3) transformation matrix A for this fit, such that y_i ~ A * x_i (with x_i in homogeneous coordinates).
      Specified by:
      getTransformationMatrix in interface LinearFit2d
      Returns:
      the transformation matrix for this fit
    • getError

      public double getError()
      Description copied from interface: LinearFit2d
      Returns the total error for this fit.
      Specified by:
      getError in interface LinearFit2d
      Returns:
      the fitting error