javax.media.jai
Class WarpPerspective

java.lang.Object
  extended byjavax.media.jai.Warp
      extended byjavax.media.jai.WarpPerspective
All Implemented Interfaces:
Serializable

public final class WarpPerspective
extends Warp

A description of a perspective (projective) warp.

The transform is specified as a mapping from destination space to source space. This is a backward mapping, as opposed to the forward mapping used in the "Affine" operation.

See Also:
Serialized Form

Constructor Summary
WarpPerspective(PerspectiveTransform transform)
          Constructs a WarpPerspective with a given transform mapping destination pixels into source space.
 
Method Summary
 PerspectiveTransform getTransform()
          Returns a clone of the PerspectiveTransform associated with this WarpPerspective object.
 Point2D mapDestPoint(Point2D destPt)
          Computes the source point corresponding to the supplied point.
 Rectangle mapDestRect(Rectangle destRect)
          Computes a Rectangle that is guaranteed to enclose the region of the source that is required in order to produce a given rectangular output region.
 Point2D mapSourcePoint(Point2D sourcePt)
          Computes the destination point corresponding to the supplied point.
 Rectangle mapSourceRect(Rectangle srcRect)
          Computes a Rectangle that is guaranteed to enclose the region of the source that is required in order to produce a given rectangular output region.
 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
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

WarpPerspective

public WarpPerspective(PerspectiveTransform transform)
Constructs a WarpPerspective 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.

Parameters:
transform - The destination to source transform.
Throws:
IllegalArgumentException - if transform is null
Method Detail

getTransform

public PerspectiveTransform getTransform()
Returns a clone of the PerspectiveTransform associated with this WarpPerspective object.

Returns:
An instance of PerspectiveTransform.

warpSparseRect

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. The destination region is specified using normal integral (full pixel) coordinates. The source positions returned by the method are specified in floating point.

Specified by:
warpSparseRect in class Warp
Parameters:
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 horizontal sampling period.
destRect - A float array containing at least 2*((width+periodX-1)/periodX)* ((height+periodY-1)/periodY) elements, or null. If null, a new array will be constructed.
Returns:
A reference to the destRect parameter if it is non-null, or a new float array otherwise.

mapDestRect

public Rectangle mapDestRect(Rectangle destRect)
Computes a Rectangle that is guaranteed to enclose the region of the source that is required in order to produce a given rectangular output region.

Overrides:
mapDestRect in class Warp
Parameters:
destRect - The Rectangle in destination coordinates.
Returns:
A Rectangle in the source coordinate system that is guaranteed to contain all pixels referenced by the output of warpRect() on the destination region.
Throws:
IllegalArgumentException - if destRect is null.

mapSourceRect

public Rectangle mapSourceRect(Rectangle srcRect)
Computes a Rectangle that is guaranteed to enclose the region of the source that is required in order to produce a given rectangular output region.

Overrides:
mapSourceRect in class Warp
Parameters:
srcRect - The Rectangle in source coordinates.
Returns:
A Rectangle in the destination coordinate system that is guaranteed to contain all pixels within the forward mapping of the source rectangle.
Throws:
IllegalArgumentException - is srcRect is null.
Since:
JAI 1.1

mapDestPoint

public Point2D mapDestPoint(Point2D destPt)
Computes the source point corresponding to the supplied point.

This method returns the return value of transform.transform(destPt, null).

Overrides:
mapDestPoint in class Warp
Parameters:
destPt - the position in destination image coordinates to map to source image coordinates.
Returns:
a Point2D of the same class as destPt.
Throws:
IllegalArgumentException - if destPt is null.
Since:
JAI 1.1.2

mapSourcePoint

public Point2D mapSourcePoint(Point2D sourcePt)
Computes the destination point corresponding to the supplied point.

If the transform is invertible, this method returns the return value of transform.inverseTransform(destPt, null). If the transform is not invertible, null is returned.

Overrides:
mapSourcePoint in class Warp
Parameters:
sourcePt - the position in source image coordinates to map to destination image coordinates.
Returns:
a Point2D of the same class as sourcePt or null> if the transform is not invertible.
Throws:
IllegalArgumentException - if sourcePt is null.
Since:
JAI 1.1.2