| java.lang.Object javax.media.jai.Warp javax.media.jai.WarpGrid
WarpGrid | final public class WarpGrid extends Warp (Code) | | A regular grid-based description of an image warp.
The mapping from destination pixels to source positions is
described by bilinear interpolation within a rectilinear grid of
points with known mappings.
Given a destination pixel coordinate (x, y) that lies within
a cell having corners at (x0, y0), (x1, y0), (x0, y1) and (x1, y1),
with source coordinates defined at each respective corner equal
to (sx0, sy0), (sx1, sy1), (sx2, sy2) and (sx3, sy3), the
source position (sx, sy) that maps onto (x, y) is given by the formulas:
xfrac = (x - x0)/(x1 - x0)
yfrac = (y - y0)/(y1 - y0)
s = sx0 + (sx1 - sx0)*xfrac
t = sy0 + (sy1 - sy0)*xfrac
u = sx2 + (sx3 - sx2)*xfrac
v = sy2 + (sy3 - sy2)*xfrac
sx = s + (u - s)*yfrac
sy = t + (v - t)*yfrac
In other words, the source x and y values are interpolated
horizontally along the top and bottom edges of the grid cell,
and the results are interpolated vertically:
(x0, y0) -> (x1, y0) ->
(sx0, sy0) (sx1, sy1)
+------------+---------+
| |\ |
| | (s, t) |
| | |
| | |
| | |
| | |
| (x, y) -> | |
| (sx, sy)--+ |
| | |
| | |
| | (u, v) |
| |/ |
+------------+---------+
(x0, y1) -> (x1, y1) ->
(sx2, sy2) (sx3, sy3)
Points outside the bounds of the cells defining the grid warp will
be mapped to the source image using the identity transformation.
WarpGrid is marked final so that it may be more easily inlined.
|
Constructor Summary | |
public | WarpGrid(int xStart, int xStep, int xNumCells, int yStart, int yStep, int yNumCells, float[] warpPositions) Constructs a WarpGrid with a given grid-based transform mapping
destination pixels into source space. | public | WarpGrid(Warp master, int xStart, int xStep, int xNumCells, int yStart, int yStep, int yNumCells) Constructs a WarpGrid object by sampling the displacements
given by another Warp object of any kind.
The grid is defined by a set of equal-sized cells.
The grid starts at (xStart, yStart). |
Method Summary | |
public int | getXNumCells() Returns the number of grid cell columns. | public int | getXStart() Returns the minimum X coordinate of the grid. | public int | getXStep() Returns the horizontal spacing between grid cells. | public float[] | getXWarpPos() Returns the horizontal warp positions at the grid points. | public int | getYNumCells() Returns the number of grid cell rows. | public int | getYStart() Returns the minimum Y coordinate of the grid. | public int | getYStep() Returns the vertical spacing between grid cells. | public float[] | getYWarpPos() Returns the vertical warp positions at the grid points. | 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:
float[] sxy = warpSparseRect((int)destPt.getX(), (int)destPt.getY(),
2, 2, 1, 1, null);
double wtRight = destPt.getX() - (int)destPt.getX();
double wtLeft = 1.0 - wtRight;
double wtBottom = destPt.getY() - (int)destPt.getY();
double wtTop = 1.0 - wtBottom;
Point2D pt = (Point2D)destPt.clone();
pt.setLocation((sxy[0]*wtLeft + sxy[2]*wtRight)*wtTop +
(sxy[4]*wtLeft + sxy[6]*wtRight)*wtBottom,
(sxy[1]*wtLeft + sxy[3]*wtRight)*wtTop +
(sxy[5]*wtLeft + sxy[7]*wtRight)*wtBottom);
Parameters: destPt - the position in destination image coordinatesto map to source image coordinates. | public float[] | warpSparseRect(int x, int y, int width, int height, int periodX, int periodY, float[] destRect) Computes the source subpixel positions for a given rectangular
destination region, subsampled with an integral period.
Points outside the bounds of the cells defining the grid warp will
be mapped to the source image using the identity transformation.
Parameters: x - The minimum X coordinate of the destination region. Parameters: y - The minimum Y coordinate of the destination region. Parameters: width - The width of the destination region. Parameters: height - The height of the destination region. Parameters: periodX - The horizontal sampling period. Parameters: periodY - The vertical sampling period. Parameters: destRect - An int array containing at least2*((width+periodX-1)/periodX)*((height+periodY-1)/periodY)elements, or null . |
WarpGrid | public WarpGrid(int xStart, int xStep, int xNumCells, int yStart, int yStep, int yNumCells, float[] warpPositions)(Code) | | Constructs a WarpGrid with a given grid-based transform mapping
destination pixels into source space. Note that this is
a backward mapping as opposed to the forward mapping used in
AffineOpImage.
The grid is defined by a set of equal-sized cells.
The grid starts at (xStart, yStart). Each cell has width
equal to xStep and height equal to yStep, and there are
xNumCells cells horizontally and yNumCells cells vertically.
The local mapping within each cell is defined by
the values in the table parameter. This parameter must
contain 2*(xNumCells + 1)*(yNumCells + 1) values, which
alternately contain the source X and Y coordinates to which
each destination grid intersection point maps.
The cells are enumerated in row-major order, that is,
all the grid points along a row are enumerated first, then
the grid points for the next row are enumerated, and so on.
As an example, suppose xNumCells is equal to 2 and
yNumCells is equal 1. Then the order of the data in table
would be:
x00, y00, x10, y10, x20, y20, x01, y01, x11, y11, x21, y21
for a total of 2*(2 + 1)*(1 + 1) = 12 elements.
Parameters: xStart - the minimum X coordinate of the grid. Parameters: xStep - the horizontal spacing between grid cells. Parameters: xNumCells - the number of grid cell columns. Parameters: yStart - the minimum Y coordinate of the grid. Parameters: yStep - the vertical spacing between grid cells. Parameters: yNumCells - the number of grid cell rows. Parameters: warpPositions - a float array of length 2*(xNumCells + 1)*(yNumCells + 1) containing the warp positions at thegrid points, in row-major order. throws: IllegalArgumentException - if the length of warpPositions is incorrect |
WarpGrid | public WarpGrid(Warp master, int xStart, int xStep, int xNumCells, int yStart, int yStep, int yNumCells)(Code) | | Constructs a WarpGrid object by sampling the displacements
given by another Warp object of any kind.
The grid is defined by a set of equal-sized cells.
The grid starts at (xStart, yStart). Each cell has width
equal to xStep and height equal to yStep, and there are
xNumCells cells horizontally and yNumCells cells vertically.
Parameters: master - the Warp object used to initialize the griddisplacements. Parameters: xStart - the minimum X coordinate of the grid. Parameters: xStep - the horizontal spacing between grid cells. Parameters: xNumCells - the number of grid cell columns. Parameters: yStart - the minimum Y coordinate of the grid. Parameters: yStep - the vertical spacing between grid cells. Parameters: yNumCells - the number of grid cell rows. |
getXNumCells | public int getXNumCells()(Code) | | Returns the number of grid cell columns.
|
getXStart | public int getXStart()(Code) | | Returns the minimum X coordinate of the grid.
|
getXStep | public int getXStep()(Code) | | Returns the horizontal spacing between grid cells.
|
getXWarpPos | public float[] getXWarpPos()(Code) | | Returns the horizontal warp positions at the grid points.
|
getYNumCells | public int getYNumCells()(Code) | | Returns the number of grid cell rows.
|
getYStart | public int getYStart()(Code) | | Returns the minimum Y coordinate of the grid.
|
getYStep | public int getYStep()(Code) | | Returns the vertical spacing between grid cells.
|
getYWarpPos | public float[] getYWarpPos()(Code) | | Returns the vertical warp positions at the grid points.
|
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:
float[] sxy = warpSparseRect((int)destPt.getX(), (int)destPt.getY(),
2, 2, 1, 1, null);
double wtRight = destPt.getX() - (int)destPt.getX();
double wtLeft = 1.0 - wtRight;
double wtBottom = destPt.getY() - (int)destPt.getY();
double wtTop = 1.0 - wtBottom;
Point2D pt = (Point2D)destPt.clone();
pt.setLocation((sxy[0]*wtLeft + sxy[2]*wtRight)*wtTop +
(sxy[4]*wtLeft + sxy[6]*wtRight)*wtBottom,
(sxy[1]*wtLeft + sxy[3]*wtRight)*wtTop +
(sxy[5]*wtLeft + sxy[7]*wtRight)*wtBottom);
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 |
warpSparseRect | public float[] warpSparseRect(int x, int y, int width, int height, int periodX, int periodY, float[] destRect)(Code) | | Computes the source subpixel positions for a given rectangular
destination region, subsampled with an integral period.
Points outside the bounds of the cells defining the grid warp will
be mapped to the source image using the identity transformation.
Parameters: x - The minimum X coordinate of the destination region. Parameters: y - The minimum Y coordinate of the destination region. Parameters: width - The width of the destination region. Parameters: height - The height of the destination region. Parameters: periodX - The horizontal sampling period. Parameters: periodY - The vertical sampling period. Parameters: destRect - An int array containing at least2*((width+periodX-1)/periodX)*((height+periodY-1)/periodY)elements, or null . If null , anew array will be constructed. a reference to the destRect parameter if it isnon-null , or a new int array of length2*width*height otherwise. throws: ArrayBoundsException - if destRect is too small |
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)
|
|
|