|
|||||||||
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.WarpGrid
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)
WarpGrid is marked final so that it may be more easily inlined.
Constructor Summary | |
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. |
|
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. |
Method Summary | |
int |
getXNumCells()
Returns the number of grid cell columns. |
int |
getXStart()
Returns the minimum X coordinate of the grid. |
int |
getXStep()
Returns the horizontal spacing between grid cells. |
float[] |
getXWarpPos()
Returns the horizontal warp positions at the grid points. |
int |
getYNumCells()
Returns the number of grid cell rows. |
int |
getYStart()
Returns the minimum Y coordinate of the grid. |
int |
getYStep()
Returns the vertical spacing between grid cells. |
float[] |
getYWarpPos()
Returns the vertical warp positions at the grid points. |
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. |
Methods inherited from class javax.media.jai.Warp |
mapDestRect,
mapSourceRect,
warpPoint,
warpPoint,
warpRect,
warpRect,
warpSparseRect |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public WarpGrid(int xStart, int xStep, int xNumCells, int yStart, int yStep, int yNumCells, float[] warpPositions)
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, y21for a total of 2*(2 + 1)*(1 + 1) = 12 elements.
xStart
- the minimum X coordinate of the grid.xStep
- the horizontal spacing between grid cells.xNumCells
- the number of grid cell columns.yStart
- the minimum Y coordinate of the grid.yStep
- the vertical spacing between grid cells.yNumCells
- the number of grid cell rows.warpPositions
- a float array of length 2*(xNumCells + 1)*
(yNumCells + 1) containing the warp positions at the
grid points, in row-major order.public WarpGrid(Warp master, int xStart, int xStep, int xNumCells, int yStart, int yStep, int yNumCells)
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.
master
- the Warp object used to initialize the grid
displacements.xStart
- the minimum X coordinate of the grid.xStep
- the horizontal spacing between grid cells.xNumCells
- the number of grid cell columns.yStart
- the minimum Y coordinate of the grid.yStep
- the vertical spacing between grid cells.yNumCells
- the number of grid cell rows.Method Detail |
public int getXStart()
public int getYStart()
public int getXStep()
public int getYStep()
public int getXNumCells()
public int getYNumCells()
public float[] getXWarpPos()
public float[] getYWarpPos()
public float[] warpSparseRect(int x, int y, int width, int height, int periodX, int periodY, float[] destRect)
x
- The minimum X coordinate of the destination region.y
- The minimum Y coordinate of the destination region.width
- The width of the destination region.height
- The height of the destination region.periodX
- The horizontal sampling period.periodY
- The vertical sampling period.destRect
- An int array containing at least
2*((width+periodX-1)/periodX)*((height+periodY-1)/periodY)
elements, or null
. If null
, a
new array will be constructed.null
, or a new int array of length
2*width*height otherwise.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |