javax.media.jai
Class StatisticsOpImage

java.lang.Object
  |
  +--javax.media.jai.PlanarImage
        |
        +--javax.media.jai.OpImage
              |
              +--javax.media.jai.StatisticsOpImage

public abstract class StatisticsOpImage
extends OpImage

An abstract base class for image operators that compute statistics on a given region of an image, and with a given sampling rate.

StatisticsOpImage simply passes pixels through unchanged from its parent image. However, the desired statistics are computed on demand and made available as a property or set of properties on the image.

All instances of StatisticsOpImage make use of a region of interest, specified as a ROI object. Additionally, they may perform spatial subsampling of the region of interest according to xPeriod and yPeriod parameters that may vary from 1 (sample every pixel of the region of interest) upwards. This allows the speed and quality of statistics gathering to be traded off against one another.

Subclasses provide implementations of the getStatisticsNames, createStatistics, and accumulateStatistics methods.

See Also:
OpImage

Field Summary
protected  int maxHeight
          The largest allowable height of the source argument to accumulateStatistics.
protected  int maxWidth
          The largest allowable width of the source argument to accumulateStatistics.
protected  java.util.Hashtable properties
          A Hashtable containing all the properties generated, hashed by property names.
protected  ROI roi
          The region of interest over which to compute the statistics.
protected  int xPeriod
          The horizontal sampling rate.
protected  int xStart
          The X coordinate of the initial sample.
protected  int yPeriod
          The vertical sampling rate.
protected  int yStart
          The Y coordinate of the initial sample.
 
Fields inherited from class javax.media.jai.OpImage
cache, cobbleSources, extenders, OP_COMPUTE_BOUND, OP_IO_BOUND, OP_NETWORK_BOUND
 
Fields inherited from class javax.media.jai.PlanarImage
colorModel, height, minX, minY, sampleModel, snapshot, source0, source1, sources, tileGridXOffset, tileGridYOffset, tileHeight, tileWidth, width
 
Constructor Summary
StatisticsOpImage(java.awt.image.RenderedImage source, ROI roi, int xStart, int yStart, int xPeriod, int yPeriod, int maxWidth, int maxHeight)
          Constructs a StatisticsOpImage.
 
Method Summary
protected abstract  void accumulateStatistics(java.lang.String name, java.awt.image.Raster source, java.lang.Object stats)
          Accumulates statistics on the specified region into the previously created statistics object.
protected abstract  java.lang.Object createStatistics(java.lang.String name)
          Returns an object that will be used to gather the named statistic.
 java.lang.Object getProperty(java.lang.String name)
          Returns one of the available statistics as a property.
 java.lang.String[] getPropertyNames()
          Returns a list of property names that are recognized by this image.
protected abstract  java.lang.String[] getStatisticsNames()
          Returns a list of names of statistics understood by this class.
 java.awt.image.Raster getTile(int tileX, int tileY)
          Returns a tile for reading.
 java.awt.Rectangle mapDestRect(java.awt.Rectangle destRect, int sourceIndex)
          Maps the destination rectangle into source space unchanged.
 java.awt.Rectangle mapSourceRect(java.awt.Rectangle sourceRect, int sourceIndex)
          Maps the source rectangle into destination space unchanged.
 
Methods inherited from class javax.media.jai.OpImage
addTileToCache, computeRect, computeRect, computesUniqueTiles, computeTile, finalize, getExpandedNumBands, getFormatTags, getOperationComputeType, getTileDependencies, getTileFromCache, getTiles, hasExtender, prefetchTiles, setTileCache
 
Methods inherited from class javax.media.jai.PlanarImage
addSink, addSource, copyData, copyData, copyExtendedData, createColorModel, createSnapshot, dispose, getAsBufferedImage, getAsBufferedImage, getBounds, getColorModel, getData, getData, getExtendedData, getGraphics, getHeight, getMaxTileX, getMaxTileY, getMaxX, getMaxY, getMinTileX, getMinTileY, getMinX, getMinY, getNumSources, getNumXTiles, getNumYTiles, getProperties, getPropertyNames, getSampleModel, getSinks, getSource, getSources, getSplits, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileRect, getTileWidth, getWidth, removeSink, removeSinks, removeSource, removeSources, setImageParameters, setImageParameters, setProperties, setProperty, setSources, tileXToX, tileXToX, tileYToY, tileYToY, wrapRenderedImage, XToTileX, XToTileX, YToTileY, YToTileY
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

roi

protected ROI roi
The region of interest over which to compute the statistics.

xStart

protected int xStart
The X coordinate of the initial sample.

yStart

protected int yStart
The Y coordinate of the initial sample.

xPeriod

protected int xPeriod
The horizontal sampling rate.

yPeriod

protected int yPeriod
The vertical sampling rate.

maxWidth

protected int maxWidth
The largest allowable width of the source argument to accumulateStatistics. Subclasses may set this value by means of the corresponding constructor argument.

maxHeight

protected int maxHeight
The largest allowable height of the source argument to accumulateStatistics. Subclasses may set this value by means of the corresponding constructor argument.

properties

protected java.util.Hashtable properties
A Hashtable containing all the properties generated, hashed by property names.
Constructor Detail

StatisticsOpImage

public StatisticsOpImage(java.awt.image.RenderedImage source,
                         ROI roi,
                         int xStart,
                         int yStart,
                         int xPeriod,
                         int yPeriod,
                         int maxWidth,
                         int maxHeight)
Constructs a StatisticsOpImage. The image layout is copied from the source image.
Parameters:
source - A RenderedImage.
roi - The region of interest, as a ROI.
xStart - The initial X sample coordinate.
yStart - The initial Y sample coordinate.
xPeriod - The X sampling rate.
yPeriod - The Y sampling rate.
maxWidth - The largest allowed width for processing.
maxHeight - The largest allowed height for processing.
Method Detail

mapSourceRect

public java.awt.Rectangle mapSourceRect(java.awt.Rectangle sourceRect,
                                        int sourceIndex)
Maps the source rectangle into destination space unchanged.
Parameters:
sourceRect - the Rectangle in source coordinates.
sourceIndex - the index of the source image.
Returns:
a Rectangle indicating the required source region.
Throws:
java.lang.IllegalArgumentException - if sourceIndex is negative or greater than the index of the last source.
NullPointerException - if sourceRect is null.
Overrides:
mapSourceRect in class OpImage

mapDestRect

public java.awt.Rectangle mapDestRect(java.awt.Rectangle destRect,
                                      int sourceIndex)
Maps the destination rectangle into source space unchanged.
Parameters:
destRect - the Rectangle in destination coordinates.
sourceIndex - the index of the source image.
Returns:
a Rectangle indicating the valid destination region.
Throws:
java.lang.IllegalArgumentException - if sourceIndex is negative or greater than the index of the last source.
NullPointerException - if destRect is null.
Overrides:
mapDestRect in class OpImage

getTile

public java.awt.image.Raster getTile(int tileX,
                                     int tileY)
Returns a tile for reading. The tile request is simply forwarded to the source image.
Parameters:
tileX - the X index of the tile.
tileY - the Y index of the tile.
Returns:
the tile as a Raster.
Overrides:
getTile in class OpImage

getProperty

public java.lang.Object getProperty(java.lang.String name)
Returns one of the available statistics as a property. If the property name is not recognized, java.awt.Image.UndefinedProperty will be returned.
Overrides:
getProperty in class PlanarImage

getPropertyNames

public java.lang.String[] getPropertyNames()
Returns a list of property names that are recognized by this image.
Returns:
an array of Strings containing valid property names.
Overrides:
getPropertyNames in class PlanarImage

getStatisticsNames

protected abstract java.lang.String[] getStatisticsNames()
Returns a list of names of statistics understood by this class.

createStatistics

protected abstract java.lang.Object createStatistics(java.lang.String name)
Returns an object that will be used to gather the named statistic.
Parameters:
name - the name of the statistic to be gathered.

accumulateStatistics

protected abstract void accumulateStatistics(java.lang.String name,
                                             java.awt.image.Raster source,
                                             java.lang.Object stats)
Accumulates statistics on the specified region into the previously created statistics object. The region of interest and X and Y sampling rate should be respected.
Parameters:
name - the name of the statistic to be gathered.
source - a Raster containing source pixels. The dimensions of the Raster will not exceed maxWidth x maxHeight.
stats - a statistics object generated by a previous call to createStatistics.



Casa de Bender