Package com.irurueta.geometry.estimators
Class Point2DNormalizer
java.lang.Object
com.irurueta.geometry.estimators.Point2DNormalizer
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
FieldsModifier and TypeFieldDescriptionprivate doubleComputed x coordinate of centroid of points.private doubleComputed y coordinate of centroid of points.private ProjectiveTransformation2DTransformation to denormalize points, which corresponds to the inverse transformation.private booleanFlag indicating that this instance is locked because computation is in progress.private doubleMaximum x inhomogeneous coordinate found in provided points.private doubleMaximum y inhomogeneous coordinate found in provided points.static final intMinimum amount of points required to perform normalization.private doubleMinimum x inhomogeneous coordinate found in provided points.private doubleMinimum y inhomogeneous coordinate found in provided points.Collection of points used to compute normalization.private doubleComputed scale on x coordinates to normalize points.private doubleComputed scale on y coordinates to normalize points.private ProjectiveTransformation2DTransformation to normalize points. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcompute()Computes normalization and de-normalization transformations.private voidComputes minimum and maximum inhomogeneous point coordinates from the list of provided 2D points.doubleReturns computed x coordinate of centroid of points.doubleReturns computed y coordinate of centroid of points.Returns transformation to denormalize points, which corresponds to the inverse transformation.doubleReturns maximum x inhomogeneous coordinate found in provided points.doubleReturns maximum y inhomogeneous coordinate found in provided points.doubleReturns minimum x inhomogeneous coordinate found in provided points.doubleReturns minimum y inhomogeneous coordinate found in provided points.Returns collection of points used to compute normalization.doubleReturns computed scale to normalize points on x coordinate.doubleReturns computed scale to normalize points on y coordinate.Returns transformation to normalize points.private voidinternalSetPoints(List<Point2D> points) Sets list of points.booleanisLocked()Indicates whether this instance is locked because computation is in progress.booleanisReady()Indicates whether this instance is ready (i.e. has enough data) to start the computation.booleanIndicates whether result (i.e. transformation and inverse transformation) are available or not.private voidreset()Resets internal values.voidSets collection of points used to compute normalization.
-
Field Details
-
MIN_POINTS
public static final int MIN_POINTSMinimum amount of points required to perform normalization.- See Also:
-
points
Collection of points used to compute normalization. -
locked
private boolean lockedFlag indicating that this instance is locked because computation is in progress. -
minInhomX
private double minInhomXMinimum x inhomogeneous coordinate found in provided points. -
minInhomY
private double minInhomYMinimum y inhomogeneous coordinate found in provided points. -
maxInhomX
private double maxInhomXMaximum x inhomogeneous coordinate found in provided points. -
maxInhomY
private double maxInhomYMaximum y inhomogeneous coordinate found in provided points. -
scaleX
private double scaleXComputed scale on x coordinates to normalize points. -
scaleY
private double scaleYComputed scale on y coordinates to normalize points. -
centroidX
private double centroidXComputed x coordinate of centroid of points. -
centroidY
private double centroidYComputed y coordinate of centroid of points. -
transformation
Transformation to normalize points. -
inverseTransformation
Transformation to denormalize points, which corresponds to the inverse transformation.
-
-
Constructor Details
-
Point2DNormalizer
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
Returns collection of points used to compute normalization.- Returns:
- collection of points used to compute normalization.
-
setPoints
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
Returns transformation to normalize points.- Returns:
- transformation to normalize points.
-
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
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
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.
-