javax.media.jai
Class ImagePyramid

java.lang.Object
  extended byjavax.media.jai.ImageMIPMap
      extended byjavax.media.jai.ImagePyramid
All Implemented Interfaces:
ImageJAI, PropertyChangeEmitter, PropertySource, WritablePropertySource

public class ImagePyramid
extends ImageMIPMap

A class implementing the "Pyramid" operation on a RenderedImage. Given a RenderedImage which represents the image at the highest resolution level, the images at lower resolution levels may be derived by performing a specific chain of operations to downsample the image at the higher resolution level repeatedly. Similarly, once an image at a lower resolution level is obtained, the images at higher resolution levels may be retrieved by performing a specific chain of operations to upsample the image at the lower resolution level repeatedly.

When an image is downsampled, the image at the higher resolution level is lost. However, the difference image between the original image and the image obtained by up sampling the downsampled result image is saved. This difference image, combined with the up sampling operations is used to retrieve the image at a higher resolution level from the image at a lower resolution level.

This is a bi-directional operation. A user may request an image at any resolution level greater than or equal to the highest resolution level, which is defined as level 0.

The downSampler is a chain of operations that is used to derive the image at the next lower resolution level from the image at the current resolution level. That is, given an image at resolution level i, downSampler is used to obtain the image at resolution level i+1. The chain may contain one or more operation nodes; however, each node must be a RenderedOp. The parameter points to the last node in the chain. The very first node in the chain must be a RenderedOp that takes one RenderedImage as its source. All other nodes may have multiple sources. When traversing back up the chain, if a node has more than one source, the first source, source0, is used to move up the chain. This parameter is saved by reference.

The upSampler is a chain of operations that is used to derive the image at the next higher resolution level from the image at the current resolution level. That is, given an image at resolution level i, upSampler is used to obtain the image at resolution level i-1. The requirement for this parameter is identical to that of the downSampler parameter.

The differencer is a chain of operations that is used to find the difference between an image at a particular resolution level and the image obtained by first down sampling that image then up sampling the result image of the down sampling operations. The chain may contain one or more operation nodes; however, each node must be a RenderedOp. The parameter points to the last node in the chain. The very first node in the chain must be a RenderedOp that takes two RenderedImages as its sources. When traversing back up the chain, if a node has more than one source, the first source, source0, is used to move up the chain. This parameter is saved by reference.

The combiner is a chain of operations that is used to combine the result image of the up sampling operations and the difference image saved to retrieve an image at a higher resolution level. The requirement for this parameter is identical to that of the differencer parameter.

Reference: "The Laplacian Pyramid as a Compact Image Code" Peter J. Burt and Edward H. Adelson IEEE Transactions on Communications, Vol. COM-31, No. 4, April 1983

See Also:
ImageMIPMap

Field Summary
protected  RenderedOp combiner
          The operation chain used to combine two images.
protected  RenderedOp differencer
          The operation chain used to differ two images.
protected  RenderedOp upSampler
          The operation chain used to derive the higher resolution images.
 
Fields inherited from class javax.media.jai.ImageMIPMap
currentImage, currentLevel, downSampler, eventManager, highestImage, properties
 
Constructor Summary
protected ImagePyramid()
          The default constructor.
  ImagePyramid(RenderedImage image, RenderedOp downSampler, RenderedOp upSampler, RenderedOp differencer, RenderedOp combiner)
          Constructor.
  ImagePyramid(RenderedOp downSampler, RenderedOp upSampler, RenderedOp differencer, RenderedOp combiner)
          Constructor.
 
Method Summary
 RenderedImage getDiffImage()
          Returns the difference image between the current image and the image obtained by first down sampling the current image then up sampling the result image of down sampling.
 RenderedImage getDownImage()
          Returns the image at the next lower resolution level, obtained by applying the downSampler on the image at the current resolution level.
 RenderedImage getImage(int level)
          Returns the image at the specified resolution level.
 RenderedImage getUpImage()
          Returns the image at the previous higher resolution level, If the current image is already at level 0, then the current image will be returned without further up sampling.
 
Methods inherited from class javax.media.jai.ImageMIPMap
addPropertyChangeListener, addPropertyChangeListener, duplicate, getAsRenderable, getAsRenderable, getCurrentImage, getCurrentLevel, getProperty, getPropertyClass, getPropertyNames, getPropertyNames, removeProperty, removePropertyChangeListener, removePropertyChangeListener, setProperty, vectorize, vectorize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

upSampler

protected RenderedOp upSampler
The operation chain used to derive the higher resolution images.


differencer

protected RenderedOp differencer
The operation chain used to differ two images.


combiner

protected RenderedOp combiner
The operation chain used to combine two images.

Constructor Detail

ImagePyramid

protected ImagePyramid()
The default constructor.


ImagePyramid

public ImagePyramid(RenderedImage image,
                    RenderedOp downSampler,
                    RenderedOp upSampler,
                    RenderedOp differencer,
                    RenderedOp combiner)
Constructor. The RenderedOp parameters point to the last operation node in each chain. The first operation in each chain must not have any source images specified; that is, its number of sources must be 0. All input parameters are saved by reference.

Parameters:
image - The image with the highest resolution.
downSampler - The operation chain used to derive the lower resolution images.
upSampler - The operation chain used to derive the higher resolution images.
differencer - The operation chain used to differ two images.
combiner - The operation chain used to combine two images.
Throws:
IllegalArgumentException - if image is null.
IllegalArgumentException - if downSampler is null.
IllegalArgumentException - if upSampler is null.
IllegalArgumentException - if differencer is null.
IllegalArgumentException - if combiner is null.

ImagePyramid

public ImagePyramid(RenderedOp downSampler,
                    RenderedOp upSampler,
                    RenderedOp differencer,
                    RenderedOp combiner)
Constructor. The RenderedOp parameters point to the last operation node in each chain. The first operation in the downSampler chain must have the image with the highest resolution as its source. The first operation in all other chains must not have any source images specified; that is, its number of sources must be 0. All input parameters are saved by reference.

Parameters:
downSampler - The operation chain used to derive the lower resolution images.
upSampler - The operation chain used to derive the higher resolution images.
differencer - The operation chain used to differ two images.
combiner - The operation chain used to combine two images.
Throws:
IllegalArgumentException - if downSampler is null.
IllegalArgumentException - if upSampler is null.
IllegalArgumentException - if differencer is null.
IllegalArgumentException - if combiner is null.
IllegalArgumentException - if downSampler has no sources.
IllegalArgumentException - if an object other than a RenderedImage is found in the downSampler chain.
Method Detail

getImage

public RenderedImage getImage(int level)
Returns the image at the specified resolution level. The requested level must be greater than or equal to 0 or null will be returned. The image is obtained by either down sampling or up sampling the current image.

Overrides:
getImage in class ImageMIPMap
Parameters:
level - The specified resolution level.

getDownImage

public RenderedImage getDownImage()
Returns the image at the next lower resolution level, obtained by applying the downSampler on the image at the current resolution level.

Overrides:
getDownImage in class ImageMIPMap

getUpImage

public RenderedImage getUpImage()
Returns the image at the previous higher resolution level, If the current image is already at level 0, then the current image will be returned without further up sampling.

The image is obtained by first up sampling the current image, then combine the result image with the previously saved difference image using the combiner op chain.


getDiffImage

public RenderedImage getDiffImage()
Returns the difference image between the current image and the image obtained by first down sampling the current image then up sampling the result image of down sampling. This is done using the differencer op chain. The current level and current image will not be changed.