| java.lang.Object javax.media.jai.Warp javax.media.jai.WarpPolynomial
All known Subclasses: javax.media.jai.WarpQuadratic, javax.media.jai.WarpGeneralPolynomial, javax.media.jai.WarpCubic, javax.media.jai.WarpAffine,
WarpPolynomial | abstract public class WarpPolynomial extends Warp (Code) | | 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.
See Also: WarpAffine See Also: WarpQuadratic See Also: WarpCubic See Also: WarpGeneralPolynomial |
Field 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 | |
public | 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. | public | WarpPolynomial(float[] xCoeffs, float[] yCoeffs) Constructs a WarpPolynomial with pre- and post-scale factors of 1. |
Method Summary | |
public 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. | public float[][] | getCoeffs() Returns the raw coefficients array for both the X and Y coordinate mapping. | public int | getDegree() Returns the degree of the warp polynomials. | public float | getPostScaleX() Returns the scaling factor applied to the result of the X polynomial. | public float | getPostScaleY() Returns the scaling factor applied to the result of the Y polynomial. | public float | getPreScaleX() Returns the scaling factor applied to input (dest) X coordinates. | public float | getPreScaleY() Returns the scaling factor applied to input (dest) Y coordinates. | public float[] | getXCoeffs() Returns the raw coefficients array for the X coordinate mapping. | public float[] | getYCoeffs() Returns the raw coefficients array for the Y coordinate mapping. | public Point2D | mapDestPoint(Point2D destPt) Computes the source point corresponding to the supplied point.
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);
Parameters: destPt - the position in destination image coordinatesto map to source image coordinates. |
degree | protected int degree(Code) | | The degree of the polynomial, determined by the number of
coefficients supplied via the X and Y coefficients arrays.
|
postScaleX | protected float postScaleX(Code) | | 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.
|
postScaleY | protected float postScaleY(Code) | | 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.
|
preScaleX | protected float preScaleX(Code) | | A scaling factor applied to input (dest) x coordinates to
improve computational accuracy.
|
preScaleY | protected float preScaleY(Code) | | A scaling factor applied to input (dest) y coordinates to
improve computational accuracy.
|
xCoeffs | protected float[] xCoeffs(Code) | | An array of coefficients that maps a destination point to
the source's X coordinate.
|
yCoeffs | protected float[] yCoeffs(Code) | | An array of coefficients that maps a destination point to
the source's Y coordinate.
|
WarpPolynomial | public WarpPolynomial(float[] xCoeffs, float[] yCoeffs, float preScaleX, float preScaleY, float postScaleX, float postScaleY)(Code) | | Constructs a WarpPolynomial with a given transform mapping
destination pixels into source space. Note that this is
a backward mapping as opposed to the forward mapping used in
AffineOpImage.
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^n
and coefficients of value 0 cannot be omitted.
The destination (x, y) coordinates are multiplied by the
factors preScaleX and preScaleY prior to the evaluation of the
polynomial. The results of the polynomial evaluations are
multiplied by postScaleX and postScaleY to produce the source
pixel coordinates. This process allows for better precision of
the results.
Parameters: xCoeffs - The destination to source transform coefficients forthe X coordinate. Parameters: yCoeffs - The destination to source transform coefficients forthe Y coordinate. Parameters: preScaleX - The scale factor to apply to input (dest) X positions. Parameters: preScaleY - The scale factor to apply to input (dest) Y positions. Parameters: postScaleX - The scale factor to apply to the X polynomial output. Parameters: postScaleY - The scale factor to apply to the Y polynomial output. throws: IllegalArgumentException - if xCoeff or yCoeff have an illegal number of entries. |
WarpPolynomial | public WarpPolynomial(float[] xCoeffs, float[] yCoeffs)(Code) | | Constructs a WarpPolynomial with pre- and post-scale factors of 1.
Parameters: xCoeffs - The destination to source transform coefficients forthe X coordinate. Parameters: yCoeffs - The destination to source transform coefficients forthe Y coordinate. |
createWarp | public static WarpPolynomial createWarp(float[] sourceCoords, int sourceOffset, float[] destCoords, int destOffset, int numCoords, float preScaleX, float preScaleY, float postScaleX, float postScaleY, int degree)(Code) | | Returns an instance of 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.
Parameters: sourceCoords - An array of float s containing thesource coordinates with X and Y alternating. Parameters: sourceOffset - the initial entry of sourceCoords to be used. Parameters: destCoords - An array of float s containing thedestination coordinates with X and Y alternating. Parameters: destOffset - The initial entry of destCoords to be used. Parameters: numCoords - The number of coordinates fromsourceCoords and destCoords to be used. Parameters: preScaleX - The scale factor to apply to input (dest) X positions. Parameters: preScaleY - The scale factor to apply to input (dest) Y positions. Parameters: postScaleX - The scale factor to apply to X polynomial output. Parameters: postScaleY - The scale factor to apply to the Y polynomial output. Parameters: degree - The desired degree of the warp polynomials. An instance of WarpPolynomial . throws: IllegalArgumentException - if arrays sourceCoords or destCoordsare too small |
getCoeffs | public float[][] getCoeffs()(Code) | | Returns the raw coefficients array for both the X and Y coordinate mapping.
A cloned two-dimensional array of float s giving thepolynomial coefficients for the X and Y coordinate mapping. |
getDegree | public int getDegree()(Code) | | Returns the degree of the warp polynomials.
The degree as an int . |
getPostScaleX | public float getPostScaleX()(Code) | | Returns the scaling factor applied to the result of the X polynomial.
|
getPostScaleY | public float getPostScaleY()(Code) | | Returns the scaling factor applied to the result of the Y polynomial.
|
getPreScaleX | public float getPreScaleX()(Code) | | Returns the scaling factor applied to input (dest) X coordinates.
|
getPreScaleY | public float getPreScaleY()(Code) | | Returns the scaling factor applied to input (dest) Y coordinates.
|
getXCoeffs | public float[] getXCoeffs()(Code) | | Returns the raw coefficients array for the X coordinate mapping.
A cloned array of float s giving thepolynomial coefficients for the X coordinate mapping. |
getYCoeffs | public float[] getYCoeffs()(Code) | | Returns the raw coefficients array for the Y coordinate mapping.
A cloned array of float s giving thepolynomial coefficients for the Y coordinate mapping. |
mapDestPoint | public Point2D mapDestPoint(Point2D destPt)(Code) | | Computes the source point corresponding to the supplied point.
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);
Parameters: destPt - the position in destination image coordinatesto map to source image coordinates. a Point2D of the same class asdestPt . throws: IllegalArgumentException - if destPt isnull . since: JAI 1.1.2 |
Methods inherited from javax.media.jai.Warp | public Point2D mapDestPoint(Point2D destPt)(Code)(Java Doc) public Rectangle mapDestRect(Rectangle destRect)(Code)(Java Doc) public Point2D mapSourcePoint(Point2D sourcePt)(Code)(Java Doc) public Rectangle mapSourceRect(Rectangle sourceRect)(Code)(Java Doc) public int[] warpPoint(int x, int y, int subsampleBitsH, int subsampleBitsV, int[] destRect)(Code)(Java Doc) public float[] warpPoint(int x, int y, float[] destRect)(Code)(Java Doc) public int[] warpRect(int x, int y, int width, int height, int subsampleBitsH, int subsampleBitsV, int[] destRect)(Code)(Java Doc) public float[] warpRect(int x, int y, int width, int height, float[] destRect)(Code)(Java Doc) public int[] warpSparseRect(int x, int y, int width, int height, int periodX, int periodY, int subsampleBitsH, int subsampleBitsV, int[] destRect)(Code)(Java Doc) abstract public float[] warpSparseRect(int x, int y, int width, int height, int periodX, int periodY, float[] destRect)(Code)(Java Doc)
|
|
|