it.geosolutions.jaiext.stats
Class StatisticsOpImage

java.lang.Object
  extended by javax.media.jai.PlanarImage
      extended by javax.media.jai.OpImage
          extended by it.geosolutions.jaiext.stats.StatisticsOpImage
All Implemented Interfaces:
RenderedImage, javax.media.jai.ImageJAI, javax.media.jai.PropertyChangeEmitter, javax.media.jai.PropertySource, javax.media.jai.WritablePropertySource
Direct Known Subclasses:
ComplexStatsOpImage, SimpleStatsOpImage

public abstract class StatisticsOpImage
extends javax.media.jai.OpImage

This abstract class is used for defining the common methods for calculating image statistics. There are 2 subclasses of this class called SimpleStatsOpImage and ComplexStatsOpImage. The first one is used for calculating simple statistics which does not requests the use of an array for saving all the values, instead of the second class which stores the statistics on an array and then performs the final computations when the result is requested. The 2 subclasses must only update their constructor for adding a control on which kind of statistics are calculated and defining the computeTile() method which is used for calculating the statistics for each tile.


Field Summary
protected  int[] bands
          Array containing the indexes of the selected bands
protected  int bandsNumber
          Image bands number
protected  boolean[] booleanLookupTable
          Boolean lookuptable used if no data are present
protected  boolean caseA
          Boolean indicating that there No Data and ROI are not used
protected  boolean caseB
          Boolean indicating that only ROI is used
protected  boolean caseC
          Boolean indicating that only No Data are used
protected  AtomicBoolean firstTime
          Boolean indicating if the statistics have been already calculated(if false) or not
protected  boolean hasNoData
          Boolean indicating if a No Data Range is used
protected  boolean hasROI
          Boolean indicating if a ROI object is used
protected  Range noData
          No Data Range
protected static javax.media.jai.BorderExtender ROI_EXTENDER
          ROI extender
protected  Rectangle roiBounds
          Rectangle containing ROI bounds
protected  javax.media.jai.iterator.RandomIter roiIter
          Random Iterator used iterating on the ROI data
protected  int selectedBands
          Selected bands number
protected  javax.media.jai.PlanarImage srcROIImage
          ROI image
protected  javax.media.jai.RenderedOp srcROIImgExt
          Extended ROI image
protected  int statNum
          Length of the statsTypes array
protected  Statistics[][] stats
          Object containing the current statistics for the selected bands and for the selected statistic types
protected  Statistics.StatsType[] statsTypes
          Array containing the type of statistics to calculate
protected  boolean useROIAccessor
          Boolean indicating if a ROI RasterAccessor should be used
protected  int xPeriod
          Horizontal subsampling
protected  int yPeriod
          Vertical subsampling
 
Fields inherited from class javax.media.jai.OpImage
cache, cobbleSources, OP_COMPUTE_BOUND, OP_IO_BOUND, OP_NETWORK_BOUND, tileCacheMetric, tileRecycler
 
Fields inherited from class javax.media.jai.PlanarImage
colorModel, eventManager, height, minX, minY, properties, sampleModel, tileFactory, tileGridXOffset, tileGridYOffset, tileHeight, tileWidth, width
 
Constructor Summary
StatisticsOpImage(RenderedImage source, javax.media.jai.ImageLayout layout, Map configuration, int xPeriod, int yPeriod, javax.media.jai.ROI roi, Range noData, boolean useROIAccessor, int[] bands, Statistics.StatsType[] statsTypes, double[] minBound, double[] maxBound, int[] numBins)
           
 
Method Summary
protected  void byteLoop(javax.media.jai.RasterAccessor src, Rectangle srcRect, javax.media.jai.RasterAccessor roi, Statistics[][] statArray)
           
 void clearStatistic()
          This method is used if the user needs to perform again the statistical calculations.
 void dispose()
          When the dispose method is called, then old dispose method is performed and also the statistic container is cleared.
protected  void doubleLoop(javax.media.jai.RasterAccessor src, Rectangle srcRect, javax.media.jai.RasterAccessor roi, Statistics[][] statArray)
           
protected  void floatLoop(javax.media.jai.RasterAccessor src, Rectangle srcRect, javax.media.jai.RasterAccessor roi, Statistics[][] statArray)
           
 Object getProperty(String name)
          Get the specified property.
 String[] getPropertyNames()
          Returns a list of property names that are recognized by this image.
 Raster[] getTiles()
          Computes and returns all tiles in the image.
protected  void intLoop(javax.media.jai.RasterAccessor src, Rectangle srcRect, javax.media.jai.RasterAccessor roi, Statistics[][] statArray)
           
 Rectangle mapDestRect(Rectangle destRect, int sourceIndex)
           
 Rectangle mapSourceRect(Rectangle sourceRect, int sourceIndex)
           
protected  void shortLoop(javax.media.jai.RasterAccessor src, Rectangle srcRect, javax.media.jai.RasterAccessor roi, Statistics[][] statArray)
           
protected  void ushortLoop(javax.media.jai.RasterAccessor src, Rectangle srcRect, javax.media.jai.RasterAccessor roi, Statistics[][] statArray)
           
 
Methods inherited from class javax.media.jai.OpImage
addTileToCache, cancelTiles, computeRect, computeRect, computesUniqueTiles, computeTile, createTile, getExpandedNumBands, getFormatTags, getOperationComputeType, getTile, getTileCache, getTileCacheMetric, getTileDependencies, getTileFromCache, getTileRecycler, getTiles, hasExtender, mapDestPoint, mapSourcePoint, prefetchTiles, queueTiles, recycleTile, setTileCache, vectorize, vectorize, vectorize
 
Methods inherited from class javax.media.jai.PlanarImage
addPropertyChangeListener, addPropertyChangeListener, addSink, addSink, addSource, addTileComputationListener, copyData, copyData, copyExtendedData, createColorModel, createSnapshot, createWritableRaster, finalize, getAsBufferedImage, getAsBufferedImage, getBounds, getColorModel, getData, getData, getDefaultColorModel, getExtendedData, getGraphics, getHeight, getImageID, getMaxTileX, getMaxTileY, getMaxX, getMaxY, getMinTileX, getMinTileY, getMinX, getMinY, getNumBands, getNumSources, getNumXTiles, getNumYTiles, getProperties, getPropertyClass, getPropertyNames, getSampleModel, getSinks, getSource, getSourceImage, getSourceObject, getSources, getSplits, getTileComputationListeners, getTileFactory, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileIndices, getTileRect, getTileWidth, getWidth, overlapsMultipleTiles, removeProperty, removePropertyChangeListener, removePropertyChangeListener, removeSink, removeSink, removeSinks, removeSource, removeSources, removeTileComputationListener, setImageLayout, setProperties, setProperty, setSource, setSources, tileXToX, tileXToX, tileYToY, tileYToY, toString, wrapRenderedImage, XToTileX, XToTileX, YToTileY, YToTileY
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ROI_EXTENDER

protected static final javax.media.jai.BorderExtender ROI_EXTENDER
ROI extender


stats

protected Statistics[][] stats
Object containing the current statistics for the selected bands and for the selected statistic types


hasNoData

protected final boolean hasNoData
Boolean indicating if a No Data Range is used


hasROI

protected final boolean hasROI
Boolean indicating if a ROI object is used


useROIAccessor

protected final boolean useROIAccessor
Boolean indicating if a ROI RasterAccessor should be used


srcROIImage

protected final javax.media.jai.PlanarImage srcROIImage
ROI image


roiIter

protected final javax.media.jai.iterator.RandomIter roiIter
Random Iterator used iterating on the ROI data


roiBounds

protected final Rectangle roiBounds
Rectangle containing ROI bounds


caseA

protected final boolean caseA
Boolean indicating that there No Data and ROI are not used


caseB

protected final boolean caseB
Boolean indicating that only ROI is used


caseC

protected final boolean caseC
Boolean indicating that only No Data are used


bandsNumber

protected int bandsNumber
Image bands number


selectedBands

protected int selectedBands
Selected bands number


bands

protected int[] bands
Array containing the indexes of the selected bands


statsTypes

protected Statistics.StatsType[] statsTypes
Array containing the type of statistics to calculate


statNum

protected int statNum
Length of the statsTypes array


firstTime

protected AtomicBoolean firstTime
Boolean indicating if the statistics have been already calculated(if false) or not


xPeriod

protected final int xPeriod
Horizontal subsampling


yPeriod

protected final int yPeriod
Vertical subsampling


booleanLookupTable

protected final boolean[] booleanLookupTable
Boolean lookuptable used if no data are present


noData

protected Range noData
No Data Range


srcROIImgExt

protected javax.media.jai.RenderedOp srcROIImgExt
Extended ROI image

Constructor Detail

StatisticsOpImage

public StatisticsOpImage(RenderedImage source,
                         javax.media.jai.ImageLayout layout,
                         Map configuration,
                         int xPeriod,
                         int yPeriod,
                         javax.media.jai.ROI roi,
                         Range noData,
                         boolean useROIAccessor,
                         int[] bands,
                         Statistics.StatsType[] statsTypes,
                         double[] minBound,
                         double[] maxBound,
                         int[] numBins)
Method Detail

getPropertyNames

public String[] getPropertyNames()
Returns a list of property names that are recognized by this image.

Specified by:
getPropertyNames in interface RenderedImage
Specified by:
getPropertyNames in interface javax.media.jai.PropertySource
Overrides:
getPropertyNames in class javax.media.jai.PlanarImage
Returns:
An array of Strings containing valid property names.

clearStatistic

public void clearStatistic()
This method is used if the user needs to perform again the statistical calculations.


dispose

public void dispose()
When the dispose method is called, then old dispose method is performed and also the statistic container is cleared.

Overrides:
dispose in class javax.media.jai.OpImage

getTiles

public Raster[] getTiles()
Computes and returns all tiles in the image. The tiles are returned in a sequence corresponding to the row-major order of their respective tile indices. The returned array may of course be ignored, e.g., in the case of a subclass which caches the tiles and the intent is to force their computation. This method is overridden such that can be invoked only one time by using a flag for avoiding unnecessary computations.

Overrides:
getTiles in class javax.media.jai.PlanarImage

getProperty

public Object getProperty(String name)
Get the specified property.

Use this method to retrieve the calculated statistics as an array per band and per statistic types.

Specified by:
getProperty in interface RenderedImage
Specified by:
getProperty in interface javax.media.jai.PropertySource
Overrides:
getProperty in class javax.media.jai.PlanarImage
Parameters:
name - property name
Returns:
the requested property

byteLoop

protected void byteLoop(javax.media.jai.RasterAccessor src,
                        Rectangle srcRect,
                        javax.media.jai.RasterAccessor roi,
                        Statistics[][] statArray)

ushortLoop

protected void ushortLoop(javax.media.jai.RasterAccessor src,
                          Rectangle srcRect,
                          javax.media.jai.RasterAccessor roi,
                          Statistics[][] statArray)

shortLoop

protected void shortLoop(javax.media.jai.RasterAccessor src,
                         Rectangle srcRect,
                         javax.media.jai.RasterAccessor roi,
                         Statistics[][] statArray)

intLoop

protected void intLoop(javax.media.jai.RasterAccessor src,
                       Rectangle srcRect,
                       javax.media.jai.RasterAccessor roi,
                       Statistics[][] statArray)

floatLoop

protected void floatLoop(javax.media.jai.RasterAccessor src,
                         Rectangle srcRect,
                         javax.media.jai.RasterAccessor roi,
                         Statistics[][] statArray)

doubleLoop

protected void doubleLoop(javax.media.jai.RasterAccessor src,
                          Rectangle srcRect,
                          javax.media.jai.RasterAccessor roi,
                          Statistics[][] statArray)

mapDestRect

public Rectangle mapDestRect(Rectangle destRect,
                             int sourceIndex)
Specified by:
mapDestRect in class javax.media.jai.OpImage

mapSourceRect

public Rectangle mapSourceRect(Rectangle sourceRect,
                               int sourceIndex)
Specified by:
mapSourceRect in class javax.media.jai.OpImage


Copyright © 2006–2015 GeoSolutions. All rights reserved.