jjil.algorithm
Class GrayTrapWarp

java.lang.Object
  extended by jjil.core.PipelineStage
      extended by jjil.algorithm.GrayTrapWarp

public class GrayTrapWarp
extends PipelineStage

This PipelineStage warps a trapezoid in the input gray image into a rectangular output image.

Author:
webb

Constructor Summary
GrayTrapWarp(int nRowStart, int nRowEnd, int nColLeftStart, int nColRightStart, int nColLeftEnd, int nColRightEnd)
          Creates a new instance of GrayTrapWarp.
 
Method Summary
 int getColLeftEnd()
          Returns the left column position of the trapezoid in the ending row.
 int getColLeftStart()
          Returns the left column position of the trapezoid in the starting row.
 int getColRightEnd()
          Returns the right column position of the trapezoid in the ending row.
 int getColRightStart()
          Returns the right column position of the trapezoid in the starting row.
 int getRowEnd()
          Returns the ending row of the trapezoid.
 int getRowStart()
          Returns the starting row of the trapezoid.
 void push(Image image)
          Warps a trapezoidal region in the input gray image into a rectangular output image.
 void setTrapezoid(int nRowStart, int nRowEnd, int nColLeftStart, int nColRightStart, int nColLeftEnd, int nColRightEnd)
          Sets the bounds of the trapezoid.
 java.lang.String toString()
          Returns a string describing the current instance.
 
Methods inherited from class jjil.core.PipelineStage
getFront, isEmpty
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GrayTrapWarp

public GrayTrapWarp(int nRowStart,
                    int nRowEnd,
                    int nColLeftStart,
                    int nColRightStart,
                    int nColLeftEnd,
                    int nColRightEnd)
             throws Error
Creates a new instance of GrayTrapWarp. GrayTrapWarp warps a trapezoidal region in an input gray image into a rectangular output image. The top and bottom of the trapezoid are aligned with the rows of the image.

The bounds are specified here in a manner consistent with the way they are specified as array bounds -- that is, the starting bound is closed (<=) and the ending bound is open (<).

Parameters:
nRowStart - starting row of trapezoid in input image
nRowEnd - bounding row of trapezoid in input image. This is one past the actual last row processed in the input image.
nColLeftStart - left edge of trapezoid on starting row.
nColRightStart - right bound of trapezoid on starting row. This is one past the actual last column processed in the input image.
nColLeftEnd - left edge of trapezoid on ending row
nColRightEnd - right bound of trapezoid on ending row. This is one past the actual last column processed in the input image. The row referred to as the ending row is the one above the bounding row, i.e., nRowEnd.
Throws:
Error - if the trapezoid is empty or outside the bounds of any image, i.e., if nRowStart < 0, or nRowEnd <= nRowStart, or nColLeftStart <= nColRightStart, or nColLeftEnd <= nColRightEnd.
Method Detail

getColLeftEnd

public int getColLeftEnd()
Returns the left column position of the trapezoid in the ending row.

Returns:
the left edge position of the trapezoid in the ending row.

getColLeftStart

public int getColLeftStart()
Returns the left column position of the trapezoid in the starting row.

Returns:
the left edge position of the trapezoid in the starting row.

getColRightEnd

public int getColRightEnd()
Returns the right column position of the trapezoid in the ending row.

Returns:
the right edge position of the trapezoid in the ending row.

getColRightStart

public int getColRightStart()
Returns the right column position of the trapezoid in the starting row.

Returns:
the right edge position of the trapezoid in the starting row.

getRowEnd

public int getRowEnd()
Returns the ending row of the trapezoid.

Returns:
the bottom row of the trapezoid.

getRowStart

public int getRowStart()
Returns the starting row of the trapezoid.

Returns:
the top row of the trapezoid.

push

public void push(Image image)
          throws Error
Warps a trapezoidal region in the input gray image into a rectangular output image. Uses bilinear interpolation. The calculation of fractional image coordinates is done by multiplying all the coordinates by 256, to avoid floating point computation.

Specified by:
push in class PipelineStage
Parameters:
image - the input gray image.
Throws:
Error - if the input image is not gray, or the trapezoid already specified extends outside its bounds.

setTrapezoid

public void setTrapezoid(int nRowStart,
                         int nRowEnd,
                         int nColLeftStart,
                         int nColRightStart,
                         int nColLeftEnd,
                         int nColRightEnd)
                  throws Error
Sets the bounds of the trapezoid. Recreates the output image when they change. The output height is set to the input trapezoid height, and the output width is set to the larger of the trapezoid width at the first and last rows.

Parameters:
nRowStart - starting row of trapezoid in input image
nRowEnd - ending row of trapezoid in input image
nColLeftStart - left edge of trapezoid on starting row.
nColRightStart - right edge of trapezoid on starting row
nColLeftEnd - left edge of trapezoid on ending row
nColRightEnd - right edge of trapezoid on ending row
Throws:
Error - if the trapezoid is empty or outside the bounds of any image, i.e., if nRowStart < 0, or nRowEnd <= nRowStart, or nColLeftStart <= nColRightStart, or nColLeftEnd <= nColRightEnd.

toString

public java.lang.String toString()
Returns a string describing the current instance. All the constructor parameters are returned in the order specified in the constructor.

Overrides:
toString in class java.lang.Object
Returns:
The string describing the current instance. The string is of the form "jjil.algorithm.GrayTrapWarpxxx (startRow,endRow,leftColStart, rightColStart,leftColEnd,rightColEnd)"