|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.media.jai.Warp | +--javax.media.jai.WarpPolynomial
A polynomial-based description of an image warp.
The mapping is defined by two bivariate polynomial functions X(x, y) and Y(x, y) that map destination (x, y) coordinates to source X and Y positions respectively
The functions X(x, y) and Y(x, y) have the form:
SUM{i = 0 to n} {SUM{j = 0 to i}{a_ij*x^(i - j)*y^j}} where n is the degree os the polynomial
WarpAffine, WarpQuadratic, and WarpCubic are special cases of WarpPolynomial for n equal to 1, 2, and 3 respectively. WarpGeneralPolynomial provides a concrete implementation for polynomials of higher degree.
WarpAffine
,
WarpQuadratic
,
WarpCubic
,
WarpGeneralPolynomial
, Serialized FormField Summary | |
protected int |
degree
The degree of the polynomial, determined by the number of coefficients supplied via the X and Y coefficients arrays. |
protected float |
postScaleX
A scaling factor applied to the result of the X polynomial evaluation which compensates for the input scaling, so that the correctly scaled result is obtained. |
protected float |
postScaleY
A scaling factor applied to the result of the Y polynomial evaluation which compensates for the input scaling, so that the correctly scaled result is obtained. |
protected float |
preScaleX
A scaling factor applied to input (dest) x coordinates to improve computational accuracy. |
protected float |
preScaleY
A scaling factor applied to input (dest) y coordinates to improve computational accuracy. |
protected float[] |
xCoeffs
An array of coefficients that maps a destination point to the source's X coordinate. |
protected float[] |
yCoeffs
An array of coefficients that maps a destination point to the source's Y coordinate. |
Constructor Summary | |
WarpPolynomial(float[] xCoeffs,
float[] yCoeffs)
Constructs a WarpPolynomial with pre- and post-scale factors of 1. |
|
WarpPolynomial(float[] xCoeffs,
float[] yCoeffs,
float preScaleX,
float preScaleY,
float postScaleX,
float postScaleY)
Constructs a WarpPolynomial with a given transform mapping destination pixels into source space. |
Method Summary | |
static WarpPolynomial |
createWarp(float[] sourceCoords,
int sourceOffset,
float[] destCoords,
int destOffset,
int numCoords,
float preScaleX,
float preScaleY,
float postScaleX,
float postScaleY,
int degree)
Returns an instance of WarpPolynomial or its
subclasses that approximately maps the given scaled destination
image coordinates into the given scaled source image
coordinates. |
float[][] |
getCoeffs()
Returns the raw coefficients array for both the X and Y coordinate mapping. |
int |
getDegree()
Returns the degree of the warp polynomials. |
float |
getPostScaleX()
Returns the scaling factor applied to the result of the X polynomial. |
float |
getPostScaleY()
Returns the scaling factor applied to the result of the Y polynomial. |
float |
getPreScaleX()
Returns the scaling factor applied to input (dest) X coordinates. |
float |
getPreScaleY()
Returns the scaling factor applied to input (dest) Y coordinates. |
float[] |
getXCoeffs()
Returns the raw coefficients array for the X coordinate mapping. |
float[] |
getYCoeffs()
Returns the raw coefficients array for the Y coordinate mapping. |
Point2D |
mapDestPoint(Point2D destPt)
Computes the source point corresponding to the supplied point. |
Methods inherited from class javax.media.jai.Warp |
mapDestRect, mapSourcePoint, mapSourceRect, warpPoint, warpPoint, warpRect, warpRect, warpSparseRect, warpSparseRect |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected float[] xCoeffs
protected float[] yCoeffs
protected float preScaleX
protected float preScaleY
protected float postScaleX
protected float postScaleY
protected int degree
Constructor Detail |
public WarpPolynomial(float[] xCoeffs, float[] yCoeffs, float preScaleX, float preScaleY, float postScaleX, float postScaleY)
The xCoeffs
and yCoeffs
parameters
must contain the same number of coefficients of the form
(n + 1)(n + 2)/2
for some n
, where
n
is the non-negative degree power of the polynomial.
The coefficients, in order, are associated with the terms:
1, x, y, x^2, x*y, y^2, ..., x^n, x^(n - 1)*y, ..., x*y^(n - 1), y^nand coefficients of value 0 cannot be omitted.
The source (x, y) coordinate is pre-scaled by the factors preScaleX and preScaleY prior to the evaluation of the polynomial. The result of the polynomial evaluations are scaled by postScaleX and postScaleY to produce the destination pixel coordinates. This process allows for better precision of the results.
xCoeffs
- The destination to source transform coefficients for
the X coordinate.yCoeffs
- The destination to source transform coefficients for
the Y coordinate.preScaleX
- The scale factor to apply to input (dest) X positions.preScaleY
- The scale factor to apply to input (dest) Y positions.postScaleX
- The scale factor to apply to the X polynomial output.postScaleY
- The scale factor to apply to the Y polynomial output.IllegalArgumentException
- if xCoeff or yCoeff have an illegal number of entries.public WarpPolynomial(float[] xCoeffs, float[] yCoeffs)
xCoeffs
- The destination to source transform coefficients for
the X coordinate.yCoeffs
- The destination to source transform coefficients for
the Y coordinate.Method Detail |
public float[] getXCoeffs()
float
s giving the
polynomial coefficients for the X coordinate mapping.public float[] getYCoeffs()
float
s giving the
polynomial coefficients for the Y coordinate mapping.public float[][] getCoeffs()
float
s giving the
polynomial coefficients for the X and Y coordinate mapping.public float getPreScaleX()
public float getPreScaleY()
public float getPostScaleX()
public float getPostScaleY()
public int getDegree()
int
.public static WarpPolynomial createWarp(float[] sourceCoords, int sourceOffset, float[] destCoords, int destOffset, int numCoords, float preScaleX, float preScaleY, float postScaleX, float postScaleY, int degree)
WarpPolynomial
or its
subclasses that approximately maps the given scaled destination
image coordinates into the given scaled source image
coordinates. The mapping is given by:
x' = postScaleX*(xpoly(x*preScaleX, y*preScaleY)); x' = postScaleY*(ypoly(x*preScaleX, y*preScaleY));
Typically, it is useful to set preScaleX
to
1.0F/destImage.getWidth()
and
postScaleX
to srcImage.getWidth()
so
that the input and output of the polynomials lie between 0 and
1.
The degree of the polynomial is supplied as an argument.
sourceCoords
- An array of float
s containing the
source coordinates with X and Y alternating.sourceOffset
- the initial entry of sourceCoords
to be used.destCoords
- An array of float
s containing the
destination coordinates with X and Y alternating.destOffset
- The initial entry of destCoords
to be used.numCoords
- The number of coordinates from
sourceCoords
and destCoords
to be used.preScaleX
- The scale factor to apply to input (dest) X positions.preScaleY
- The scale factor to apply to input (dest) Y positions.postScaleX
- The scale factor to apply to X polynomial output.postScaleY
- The scale factor to apply to the Y polynomial output.degree
- The desired degree of the warp polynomials.WarpPolynomial
.IllegalArgumentException
- if arrays sourceCoords or destCoords
are too smallpublic Point2D mapDestPoint(Point2D destPt)
This method returns the value of pt
in the following
code snippet:
double dx = (destPt.getX() + 0.5)*preScaleX; double dy = (destPt.getY() + 0.5)*preScaleY; double sx = 0.0; double sy = 0.0; int c = 0; for(int nx = 0; nx <= degree; nx++) { for(int ny = 0; ny <= nx; ny++) { double t = Math.pow(dx, nx - ny)*Math.pow(dy, ny); sx += xCoeffs[c] * t; sy += yCoeffs[c] * t; c++; } } Point2D pt = (Point2D)destPt.clone(); pt.setLocation(sx*postScaleX - 0.5, sy*postScaleY - 0.5);
mapDestPoint
in class Warp
destPt
- the position in destination image coordinates
to map to source image coordinates.Point2D
of the same class as
destPt
.IllegalArgumentException
- if destPt
is
null
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |