Class WarpTransform2D
Object
Formattable
AbstractMathTransform
WarpTransform2D
- All Implemented Interfaces:
Serializable
,MathTransform
,MathTransform2D
Wraps an arbitrary
Warp
object as a two-dimensional transform. Calls to
transform methods are forwarded to the
warpPoint
method, or something equivalent. This implies that source
coordinates may be rounded to nearest integers before the transformation is applied.
This transform is typically used with grid coverage "Resample" operation for reprojecting an image. Source and destination coordinates are usually pixel coordinates in source and target image, which is why this transform may use integer arithmetic.
This math transform can be created alone (by invoking its public constructors directly), or it can be created by a
factory like LocalizationGrid
.
For more information on image warp, see Geometric Image Manipulation in the Programming in Java Advanced Imaging guide.
- Since:
- 2.1
- Author:
- Martin Desruisseaux, Alessio Fabiani
- See Also:
-
LocalizationGrid#getPolynomialTransform(int)
Warp
WarpOpImage
WarpDescriptor
- Serialized Form
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractMathTransform
AbstractMathTransform.Inverse
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
The maximal polynomial degree allowed.Fields inherited from class Formattable
SINGLE_LINE
-
Constructor Summary
ConstructorsModifierConstructorDescriptionWarpTransform2D
(Point2D[] srcCoords, Point2D[] dstCoords, int degree) Constructs a warp transform that approximatively maps the given source coordinates to the given destination coordinates.WarpTransform2D
(Rectangle2D srcBounds, float[] srcCoords, int srcOffset, Rectangle2D dstBounds, float[] dstCoords, int dstOffset, int numCoords, int degree) Constructs a warp transform that approximatively maps the given source coordinates to the given destination coordinates.WarpTransform2D
(Rectangle2D srcBounds, Point2D[] srcCoords, int srcOffset, Rectangle2D dstBounds, Point2D[] dstCoords, int dstOffset, int numCoords, int degree) Constructs a warp transform that approximatively maps the given source coordinates to the given destination coordinates.protected
WarpTransform2D
(Warp warp, Warp inverse) Constructs a transform using the specified warp object. -
Method Summary
Modifier and TypeMethodDescriptionstatic MathTransform2D
create
(Warp warp) Returns a transform using the specified warp object.boolean
Compares this transform with the specified object for equality.Returns the parameter descriptors for this math transform.Returns the parameter values for this math transform.int
Returns the dimension of input points.int
Returns the dimension of output points.Warp
getWarp()
Returns image warp wrapped by this transform.static Warp
getWarp
(CharSequence name, MathTransform2D transform) Returns a image warp for the specified transform.int
hashCode()
Returns a hash value for this transform.inverse()
Returns the inverse transform.boolean
Tests if this transform is the identity transform.void
transform
(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) Transforms source coordinates (usually pixel indices) into destination coordinates (usually "real world" coordinates).void
transform
(float[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) Transforms source coordinates (usually pixel indices) into destination coordinates (usually "real world" coordinates).Transforms source coordinates (usually pixel indices) into destination coordinates (usually "real world" coordinates).Methods inherited from class AbstractMathTransform
createTransformedShape, derivative, derivative, ensureNonNull, formatWKT, getName, needCopy, normalizeAngle, rollLongitude, transform, transform, transform
Methods inherited from class Formattable
cleanupThreadLocals, toString, toWKT, toWKT, toWKT, toWKT
Methods inherited from interface MathTransform
derivative, toWKT, transform, transform, transform
Methods inherited from interface MathTransform2D
createTransformedShape, derivative
-
Field Details
-
MAX_DEGREE
public static final int MAX_DEGREEThe maximal polynomial degree allowed.- Since:
- 2.4
- See Also:
-
-
Constructor Details
-
WarpTransform2D
Constructs a warp transform that approximatively maps the given source coordinates to the given destination coordinates. The transformation is performed using some polynomial warp with the degree supplied in argument. The number of points required for each degree of warp are as follows:Degree of Warp Number of Points 1 3 2 6 3 10 4 15 5 21 6 28 7 36 - Parameters:
srcCoords
- Source coordinates.dstCoords
- Desination coordinates.degree
- The desired degree of the warp polynomials.
-
WarpTransform2D
public WarpTransform2D(Rectangle2D srcBounds, Point2D[] srcCoords, int srcOffset, Rectangle2D dstBounds, Point2D[] dstCoords, int dstOffset, int numCoords, int degree) Constructs a warp transform that approximatively maps the given source coordinates to the given destination coordinates. The transformation is performed using some polynomial warp with the degree supplied in argument.- Parameters:
srcBounds
- Bounding box of source coordinates, ornull
if unknow.srcCoords
- Source coordinates.srcOffset
- The inital entry ofsrcCoords
to be used.dstBounds
- Bounding box of destination coordinates, ornull
if unknow.dstCoords
- Destination coordinates.dstOffset
- The inital entry ofdstCoords
to be used.numCoords
- The number of coordinates fromsrcCoords
anddstCoords
to be used.degree
- The desired degree of the warp polynomials.
-
WarpTransform2D
public WarpTransform2D(Rectangle2D srcBounds, float[] srcCoords, int srcOffset, Rectangle2D dstBounds, float[] dstCoords, int dstOffset, int numCoords, int degree) Constructs a warp transform that approximatively maps the given source coordinates to the given destination coordinates. The transformation is performed using some polynomial warp with the degree supplied in argument.- Parameters:
srcBounds
- Bounding box of source coordinates, ornull
if unknow.srcCoords
- Source coordinates with x and y alternating.srcOffset
- The inital entry ofsrcCoords
to be used.dstBounds
- Bounding box of destination coordinates, ornull
if unknow.dstCoords
- Destination coordinates with x and y alternating.dstOffset
- The inital entry ofdstCoords
to be used.numCoords
- The number of coordinates fromsrcCoords
anddstCoords
to be used.degree
- The desired degree of the warp polynomials.
-
WarpTransform2D
protected WarpTransform2D(Warp warp, Warp inverse) Constructs a transform using the specified warp object. Transformations will be applied using thewarpPoint
method or something equivalent.- Parameters:
warp
- The image warp to wrap into a math transform.inverse
- An image warp to uses for the inverse transform, ornull
in none.
-
-
Method Details
-
create
Returns a transform using the specified warp object. Transformations will be applied using thewarpPoint
method or something equivalent.- Parameters:
warp
- The image warp to wrap into a math transform.- Returns:
- The transform for the given warp.
-
getWarp
Returns a image warp for the specified transform. TheWarp.warpPoint
method transforms coordinates from source to target CRS. Note that JAI's warp operation needs a warp object with the opposite semantic (i.e. the image warp must transforms coordinates from target to source CRS). Consequently, consider invokinggetWarp(transform.inverse())
if the warp object is going to be used in an image reprojection.- Parameters:
name
- The image or coverage name, ornull
in unknow. Used only for formatting error message if someTransformException
are thrown by the supplied transform.transform
- The transform to returns as an image warp.- Returns:
- The warp for the given transform.
-
getWarp
public Warp getWarp()Returns image warp wrapped by this transform. TheWarp.warpPoint
method transforms coordinates from source to target CRS. Note that JAI's warp operation needs a warp object with the opposite semantic (i.e. the image warp must transforms coordinates from target to source CRS). Consequently, consider invokinginverse.getWarp()
if the warp object is going to be used in an image reprojection. -
getParameterDescriptors
Returns the parameter descriptors for this math transform.- Overrides:
getParameterDescriptors
in classAbstractMathTransform
- Returns:
- The parameter descriptors for this math transform, or
null
. - See Also:
-
getParameterValues
Returns the parameter values for this math transform.- Overrides:
getParameterValues
in classAbstractMathTransform
- Returns:
- A copy of the parameter values for this math transform, or
null
. - See Also:
-
getSourceDimensions
public int getSourceDimensions()Returns the dimension of input points.- Specified by:
getSourceDimensions
in interfaceMathTransform
- Specified by:
getSourceDimensions
in classAbstractMathTransform
- Returns:
- The dimension of input points.
-
getTargetDimensions
public int getTargetDimensions()Returns the dimension of output points.- Specified by:
getTargetDimensions
in interfaceMathTransform
- Specified by:
getTargetDimensions
in classAbstractMathTransform
- Returns:
- The dimension of output points.
-
isIdentity
public boolean isIdentity()Tests if this transform is the identity transform.- Specified by:
isIdentity
in interfaceMathTransform
- Overrides:
isIdentity
in classAbstractMathTransform
- Returns:
true
if thisMathTransform
is an identity transform;false
otherwise.
-
transform
Transforms source coordinates (usually pixel indices) into destination coordinates (usually "real world" coordinates).- Specified by:
transform
in interfaceMathTransform2D
- Overrides:
transform
in classAbstractMathTransform
- Parameters:
ptSrc
- the specified coordinate point to be transformed.ptDst
- the specified coordinate point that stores the result of transformingptSrc
, ornull
.- Returns:
- the coordinate point after transforming
ptSrc
and storing the result inptDst
. - See Also:
-
transform
public void transform(float[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) Transforms source coordinates (usually pixel indices) into destination coordinates (usually "real world" coordinates).- Specified by:
transform
in interfaceMathTransform
- Overrides:
transform
in classAbstractMathTransform
- Parameters:
srcPts
- the array containing the source point coordinates.srcOff
- the offset to the first point to be transformed in the source array.dstPts
- the array into which the transformed point coordinates are returned. May be the same thansrcPts
.dstOff
- the offset to the location of the first transformed point that is stored in the destination array.numPts
- the number of point objects to be transformed.
-
transform
public void transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) Transforms source coordinates (usually pixel indices) into destination coordinates (usually "real world" coordinates).- Specified by:
transform
in interfaceMathTransform
- Parameters:
srcPts
- the array containing the source point coordinates.srcOff
- the offset to the first point to be transformed in the source array.dstPts
- the array into which the transformed point coordinates are returned. May be the same thansrcPts
.dstOff
- the offset to the location of the first transformed point that is stored in the destination array.numPts
- the number of point objects to be transformed.
-
inverse
Returns the inverse transform.- Specified by:
inverse
in interfaceMathTransform
- Specified by:
inverse
in interfaceMathTransform2D
- Overrides:
inverse
in classAbstractMathTransform
- Returns:
- The inverse transform.
- Throws:
NoninvertibleTransformException
- if no inverse warp were specified at construction time.
-
hashCode
public int hashCode()Returns a hash value for this transform.- Overrides:
hashCode
in classAbstractMathTransform
-
equals
Compares this transform with the specified object for equality.- Overrides:
equals
in classAbstractMathTransform
- Parameters:
object
- The object to compare with this transform.- Returns:
true
if the given object is a transform of the same class and if, given identical source position, the transformed position would be the equals.
-