jjil.algorithm
Class Gray8SubImageGenerator

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

public class Gray8SubImageGenerator
extends PipelineStage

Generates sub images (cropped images positioned regularly across the input image) from an input Gray8Image. The subimages are of type Gray8SubImage which makes it possible to determine their location in the original input image.

Author:
webb

Constructor Summary
Gray8SubImageGenerator(int nWidth, int nHeight, int nXOffset, int nYOffset)
          Creates a new instance of Gray8SubImageGenerator.
 
Method Summary
 Image getFront()
          Returns the next subimage.
 boolean isEmpty()
          Returns true when no more subimages are available from the input image.
 void push(Image image)
          Reinitializes the subimage generator and prepares it to generate the first Gray8SubImage for the new input.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Gray8SubImageGenerator

public Gray8SubImageGenerator(int nWidth,
                              int nHeight,
                              int nXOffset,
                              int nYOffset)
Creates a new instance of Gray8SubImageGenerator. The parameters specify the size and spacing of the subimages. For example (20,30,10,15) generates 20x30 subimages, spaced every 10 pixels horizontally and 15 pixels vertically.

Parameters:
nWidth - The width of the generated subimage.
nHeight - The height of the generated subimage.
nXOffset - The horizontal offset from one subimage to the next.
nYOffset - The vertical offset from one subimage to the next.
Method Detail

isEmpty

public boolean isEmpty()
Returns true when no more subimages are available from the input image. isEmpty() should be called before getFront() to verify that subimages are available since it is an error to call getFront() when isEmpty() is true.

Overrides:
isEmpty in class PipelineStage
Returns:
true when no more subimages are available.

getFront

public Image getFront()
               throws Error
Returns the next subimage.

Overrides:
getFront in class PipelineStage
Returns:
a subimage within the input image, of type Gray8SubImage.
Throws:
Error - when there are no more subimages available (isEmpty() would return true.)

push

public void push(Image image)
          throws Error
Reinitializes the subimage generator and prepares it to generate the first Gray8SubImage for the new input.

Specified by:
push in class PipelineStage
Parameters:
image - The new input image (which must be of type Gray8Image).
Throws:
Error - if image is not of type Gray8Image, or is too small (less than the size of the subimages we're supposed to be generating).