Class Point2DNormalizer

java.lang.Object
com.irurueta.geometry.estimators.Point2DNormalizer

public class Point2DNormalizer extends Object
This class takes a collection of points and computes its average inhomogeneous coordinates and their scale so that a metric transformation is computed to transform points and normalize them. Normalized points are useful in many algorithms because due to the nature of floating point quantization, accuracy of the computations increase for normalized values between -1.0 and 1.0. This implementation uses point inhomogeneous coordinates, hence, it should not be used for points located at or close to infinity (i.e. very large inhomogeneous values).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private double
    Computed x coordinate of centroid of points.
    private double
    Computed y coordinate of centroid of points.
    Transformation to denormalize points, which corresponds to the inverse transformation.
    private boolean
    Flag indicating that this instance is locked because computation is in progress.
    private double
    Maximum x inhomogeneous coordinate found in provided points.
    private double
    Maximum y inhomogeneous coordinate found in provided points.
    static final int
    Minimum amount of points required to perform normalization.
    private double
    Minimum x inhomogeneous coordinate found in provided points.
    private double
    Minimum y inhomogeneous coordinate found in provided points.
    private List<Point2D>
    Collection of points used to compute normalization.
    private double
    Computed scale on x coordinates to normalize points.
    private double
    Computed scale on y coordinates to normalize points.
    Transformation to normalize points.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Computes normalization and de-normalization transformations.
    private void
    Computes minimum and maximum inhomogeneous point coordinates from the list of provided 2D points.
    double
    Returns computed x coordinate of centroid of points.
    double
    Returns computed y coordinate of centroid of points.
    Returns transformation to denormalize points, which corresponds to the inverse transformation.
    double
    Returns maximum x inhomogeneous coordinate found in provided points.
    double
    Returns maximum y inhomogeneous coordinate found in provided points.
    double
    Returns minimum x inhomogeneous coordinate found in provided points.
    double
    Returns minimum y inhomogeneous coordinate found in provided points.
    Returns collection of points used to compute normalization.
    double
    Returns computed scale to normalize points on x coordinate.
    double
    Returns computed scale to normalize points on y coordinate.
    Returns transformation to normalize points.
    private void
    Sets list of points.
    boolean
    Indicates whether this instance is locked because computation is in progress.
    boolean
    Indicates whether this instance is ready (i.e. has enough data) to start the computation.
    boolean
    Indicates whether result (i.e. transformation and inverse transformation) are available or not.
    private void
    Resets internal values.
    void
    Sets collection of points used to compute normalization.

    Methods inherited from class java.lang.Object

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

    • MIN_POINTS

      public static final int MIN_POINTS
      Minimum amount of points required to perform normalization.
      See Also:
    • points

      private List<Point2D> points
      Collection of points used to compute normalization.
    • locked

      private boolean locked
      Flag indicating that this instance is locked because computation is in progress.
    • minInhomX

      private double minInhomX
      Minimum x inhomogeneous coordinate found in provided points.
    • minInhomY

      private double minInhomY
      Minimum y inhomogeneous coordinate found in provided points.
    • maxInhomX

      private double maxInhomX
      Maximum x inhomogeneous coordinate found in provided points.
    • maxInhomY

      private double maxInhomY
      Maximum y inhomogeneous coordinate found in provided points.
    • scaleX

      private double scaleX
      Computed scale on x coordinates to normalize points.
    • scaleY

      private double scaleY
      Computed scale on y coordinates to normalize points.
    • centroidX

      private double centroidX
      Computed x coordinate of centroid of points.
    • centroidY

      private double centroidY
      Computed y coordinate of centroid of points.
    • transformation

      private ProjectiveTransformation2D transformation
      Transformation to normalize points.
    • inverseTransformation

      private ProjectiveTransformation2D inverseTransformation
      Transformation to denormalize points, which corresponds to the inverse transformation.
  • Constructor Details

    • Point2DNormalizer

      public Point2DNormalizer(List<Point2D> points)
      Constructor.
      Parameters:
      points - collection of points to be used to compute normalization.
      Throws:
      IllegalArgumentException - if provided collection of points does not contain enough points, which is MIN_POINTS.
  • Method Details

    • getPoints

      public List<Point2D> getPoints()
      Returns collection of points used to compute normalization.
      Returns:
      collection of points used to compute normalization.
    • setPoints

      public void setPoints(List<Point2D> points) throws LockedException
      Sets collection of points used to compute normalization.
      Parameters:
      points - collection of points used to compute normalization.
      Throws:
      LockedException - if instance is locked because another computation is already in progress.
      IllegalArgumentException - if provided collection of points does not contain enough points, which is MIN_POINTS.
    • isReady

      public boolean isReady()
      Indicates whether this instance is ready (i.e. has enough data) to start the computation.
      Returns:
      true if this instance is ready, false otherwise.
    • isLocked

      public boolean isLocked()
      Indicates whether this instance is locked because computation is in progress. While an instance is in progress, no parameter can be modified and no further computations can be done until instance becomes unlocked.
      Returns:
      true if instance is locked, false otherwise.
    • getMinInhomX

      public double getMinInhomX()
      Returns minimum x inhomogeneous coordinate found in provided points.
      Returns:
      minimum x inhomogeneous coordinate found in provided points.
    • getMinInhomY

      public double getMinInhomY()
      Returns minimum y inhomogeneous coordinate found in provided points.
      Returns:
      minimum y inhomogeneous coordinate found in provided points.
    • getMaxInhomX

      public double getMaxInhomX()
      Returns maximum x inhomogeneous coordinate found in provided points.
      Returns:
      maximum x inhomogeneous coordinate found in provided points.
    • getMaxInhomY

      public double getMaxInhomY()
      Returns maximum y inhomogeneous coordinate found in provided points.
      Returns:
      maximum y inhomogeneous coordinate found in provided points.
    • getScaleX

      public double getScaleX()
      Returns computed scale to normalize points on x coordinate.
      Returns:
      computed scale to normalize points on x coordinate.
    • getScaleY

      public double getScaleY()
      Returns computed scale to normalize points on y coordinate.
      Returns:
      computed scale to normalize points on y coordinate.
    • getCentroidX

      public double getCentroidX()
      Returns computed x coordinate of centroid of points.
      Returns:
      computed x coordinate of centroid of points.
    • getCentroidY

      public double getCentroidY()
      Returns computed y coordinate of centroid of points.
      Returns:
      computed y coordinate of centroid of points.
    • getTransformation

      public ProjectiveTransformation2D getTransformation()
      Returns transformation to normalize points.
      Returns:
      transformation to normalize points.
    • getInverseTransformation

      public ProjectiveTransformation2D getInverseTransformation()
      Returns transformation to denormalize points, which corresponds to the inverse transformation.
      Returns:
      transformation to denormalize points.
    • isResultAvailable

      public boolean isResultAvailable()
      Indicates whether result (i.e. transformation and inverse transformation) are available or not.
      Returns:
      true if result is available, false otherwise.
    • compute

      public void compute() throws NotReadyException, LockedException, NormalizerException
      Computes normalization and de-normalization transformations.
      Throws:
      NotReadyException - if not enough data has been provided to compute normalization.
      LockedException - if instance is locked because another computation is already in progress.
      NormalizerException - if normalization failed due to numerical degeneracy. This usually happens when all provided points are located too close to each other, which results in a singularity when computing proper normalization scale.
    • computeLimits

      private void computeLimits()
      Computes minimum and maximum inhomogeneous point coordinates from the list of provided 2D points.
    • internalSetPoints

      private void internalSetPoints(List<Point2D> points)
      Sets list of points.
      Parameters:
      points - list of points to be set.
      Throws:
      IllegalArgumentException - if not enough points are provided, which is MIN_POINTS.
    • reset

      private void reset()
      Resets internal values.