Class ProjectiveTransformBuilder
Object
MathTransformBuilder
ProjectiveTransformBuilder
- Direct Known Subclasses:
AffineTransformBuilder
,SimilarTransformBuilder
Builds MathTransform setup as Projective transformation from a list of
MappedPosition. The calculation uses least
square method. The Projective transform equation: (2D). The calculation uses least square method. Projective
transform equation:
[ x'] [ m00 m01 m02 ] [ x ] [ y'] = [ m10 m11 m12 ] [ y ] [ 1 ] [ m20 m21 1 ] [ 1 ] x' = m * xIn the case that we have more identical points we can write it like this (in Matrix):
[ x'1 ] [ x1 y1 1 0 0 0 -x'x -x'y] [ m00 ] [ x'2 ] [ x2 y2 1 0 0 0 -x'x -x'y] [ m01 ] [ . ] [ . ] [ m02 ] [ . ] [ . ] * [ m10 ] [ x'n ] = [ xn yn 1 0 0 0 -x'x -x'y] [ m11 ] [ y'1 ] [ 0 0 0 x1 y1 1 -y'x -y'y] [ m12 ] [ y'2 ] [ 0 0 0 x2 y2 1 -y'x -y'y] [ m20 ] [ . ] [ . ] [ m21 ] [ . ] [ . ] [ y'n ] [ 0 0 0 xn yn 1 -y'x -y'y] x' = A*mUsing the least square method we get this result:
m = (ATPA)-1 ATPx'
- Since:
- 2.4
- Author:
- Jan Jezek
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected GeneralMatrix
Matrix of derivationsprotected GeneralMatrix
Matrix of wightsprotected GeneralMatrix
Matrix of target valuesFields inherited from class MathTransformBuilder
mtFactory
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ProjectiveTransformBuilder
(List<MappedPosition> vectors) Creates ProjectiveTransformBuilder for the set of properties. -
Method Summary
Modifier and TypeMethodDescriptionprotected double[]
Calculates the parameters using the least square method.protected MathTransform
Calculates the math transform immediately.protected void
Fills A matrix for m = (ATPA)-1 ATPx' equationprotected void
Fills P matrix for m = (ATPA)-1 ATPx' equationprotected void
Fills x' matrix for m = (ATPA)-1 ATPx' equationClass<? extends CartesianCS>
Returns the required coordinate system type, which is cartesian CS.int
Returns the minimum number of points required by this builder, which is 4 by default.protected GeneralMatrix
Returns the matrix of parameters for Projective transformation.void
includeWeights
(boolean include) Switch whether to include weights into the calculation.Methods inherited from class MathTransformBuilder
getDimension, getErrorStatistics, getMappedPositions, getMathTransform, getName, getSourceCRS, getSourcePoints, getTargetCRS, getTargetPoints, getTransformation, printPoints, setMappedPositions, setSourcePoints, setTargetPoints, toString
-
Field Details
-
A
Matrix of derivations -
P
Matrix of wights -
X
Matrix of target values
-
-
Constructor Details
-
ProjectiveTransformBuilder
protected ProjectiveTransformBuilder() -
ProjectiveTransformBuilder
public ProjectiveTransformBuilder(List<MappedPosition> vectors) throws IllegalArgumentException, MismatchedDimensionException, MismatchedReferenceSystemException Creates ProjectiveTransformBuilder for the set of properties.- Parameters:
vectors
- list of MappedPosition- Throws:
MismatchedSizeException
- if the number of properties is not set properly.MismatchedDimensionException
- if the dimension of properties is not set properly.MismatchedReferenceSystemException
- -if there is mismatch in coordinate system in MappedPositionIllegalArgumentException
-
-
Method Details
-
getMinimumPointCount
public int getMinimumPointCount()Returns the minimum number of points required by this builder, which is 4 by default. Subclasses like affine transform builders will reduce this minimum.- Specified by:
getMinimumPointCount
in classMathTransformBuilder
- Returns:
- minimum number of points required by this builder, which is 4 by default.
-
getCoordinateSystemType
Returns the required coordinate system type, which is cartesian CS.- Overrides:
getCoordinateSystemType
in classMathTransformBuilder
- Returns:
- required coordinate system type
-
fillPMatrix
Fills P matrix for m = (ATPA)-1 ATPx' equation- Throws:
MissingInfoException
- if accuracy is not defined.
-
fillAMatrix
protected void fillAMatrix()Fills A matrix for m = (ATPA)-1 ATPx' equation -
fillXMatrix
protected void fillXMatrix()Fills x' matrix for m = (ATPA)-1 ATPx' equation -
includeWeights
Switch whether to include weights into the calculation. Weights are derived from each point accuracy. Weight p = 1 / accuracy2.- Parameters:
include
- if true then the weights will be included onto the calculation. False is default.- Throws:
MissingInfoException
- if all or some of the points does not have accuracy setup properly.
-
calculateLSM
protected double[] calculateLSM()Calculates the parameters using the least square method. The equation:m = (ATA)-1 ATx'
- Returns:
- m matrix.
-
getProjectiveMatrix
Returns the matrix of parameters for Projective transformation. This method should by override for the special cases like affine or similar transformation. The M matrix looks like this:[ m00 m01 m02 ] [ m10 m11 m12 ] [ m20 m21 1 ]
- Returns:
- Matrix M
-
computeMathTransform
Description copied from class:MathTransformBuilder
Calculates the math transform immediately.- Specified by:
computeMathTransform
in classMathTransformBuilder
- Returns:
- Math transform from
MappedPosition
.
-