public class ErrorDiffusionOpImage
extends javax.media.jai.UntiledOpImage
OpImage
implementing the error diffusion operation as described in ErrorDiffusionDescriptor
.
This OpImage
performs dithering of its source image into a single band image using a specified color map and error filter. For each
pixel in the source image the nearest entry in the color map is found and the index of this entry is assigned to the OpImage
at that
location. The color quantization error is calculated by mapping the index back through the color map. The error in each band is then "diffused" to
other neighboring pixels in the source image according to the specified error filter.
Optionally users may define a ROI and a NoData Range in order to reduce computation area or mask invalid pixel values.S
Modifier and Type | Field and Description |
---|---|
static boolean |
ARRAY_CALC
Constant indicating that the inner random iterators must pre-calculate an array of the image positions
|
protected javax.media.jai.LookupTableJAI |
colorMap
The color map which maps the
ErrorDiffusionOpImage to its source. |
protected javax.media.jai.KernelJAI |
errorKernel
The kernel associated with the selected error filter.
|
static boolean |
TILE_CACHED
Constant indicating that the inner random iterators must cache the current tile position
|
Constructor and Description |
---|
ErrorDiffusionOpImage(RenderedImage source,
Map config,
javax.media.jai.ImageLayout layout,
javax.media.jai.LookupTableJAI colorMap,
javax.media.jai.KernelJAI errorKernel,
javax.media.jai.ROI roi,
Range nodata,
int destNoData)
Constructs an ErrorDiffusionOpImage object.
|
Modifier and Type | Method and Description |
---|---|
protected void |
computeImage(Raster[] sources,
WritableRaster dest,
Rectangle destRect)
Performs error diffusion on a specified rectangle.
|
protected void |
computeImageDefault(Raster source,
WritableRaster dest,
Rectangle destRect,
javax.media.jai.iterator.RandomIter roiIter,
boolean roiContainsTile) |
protected void |
computeImageOptimized(Raster source,
WritableRaster dest,
Rectangle destRect,
javax.media.jai.iterator.RandomIter roiIter,
boolean roiContainsTile) |
computeTile, getTileDependencies, mapDestRect, mapSourceRect
addTileToCache, cancelTiles, computeRect, computeRect, computesUniqueTiles, createTile, dispose, getExpandedNumBands, getFormatTags, getOperationComputeType, getTile, getTileCache, getTileCacheMetric, getTileFromCache, getTileRecycler, getTiles, hasExtender, mapDestPoint, mapSourcePoint, prefetchTiles, queueTiles, recycleTile, setTileCache, vectorize, vectorize, vectorize
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, getProperty, getPropertyClass, getPropertyNames, getPropertyNames, getSampleModel, getSinks, getSource, getSourceImage, getSourceObject, getSources, getSplits, getTileComputationListeners, getTileFactory, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileIndices, getTileRect, getTiles, 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
public static final boolean ARRAY_CALC
public static final boolean TILE_CACHED
protected javax.media.jai.LookupTableJAI colorMap
ErrorDiffusionOpImage
to its source.protected javax.media.jai.KernelJAI errorKernel
public ErrorDiffusionOpImage(RenderedImage source, Map config, javax.media.jai.ImageLayout layout, javax.media.jai.LookupTableJAI colorMap, javax.media.jai.KernelJAI errorKernel, javax.media.jai.ROI roi, Range nodata, int destNoData)
The image dimensions are derived from the source image. The tile grid layout, SampleModel, and ColorModel may optionally be specified by an ImageLayout object. The calculation assumes that the entire color quantization error is distributed to the right and below the current pixel and the filter kernel values are handled appropriately.
source
- A RenderedImage.layout
- An ImageLayout optionally containing the tile grid layout, SampleModel, and ColorModel, or null.colorMap
- The color map to use which must have a number of bands equal to the number of bands in the source image. The offset of this
LookupTableJAI
must be the same for all bands.errorKernel
- The error filter kernel. This must have values between 0.0 and 1.0. Only the entries to the right of and on the same row as
the key entry, and those entries below of the row of the key entry are used; all other values are ignored. The values used must sum to
1.0. Note that if a 1-by-1 error filter kernel is supplied, the value of the unique kernel element is irrelevant and the output of the
algorithm will simply be the index in the supplied color map of the nearest matching color to the source pixel at the same position.protected void computeImage(Raster[] sources, WritableRaster dest, Rectangle destRect)
Rectangle
are calculated.computeImage
in class javax.media.jai.UntiledOpImage
sources
- The source image Raster.dest
- A WritableRaster tile containing the area to be computed.destRect
- The rectangle within dest to be processed.protected void computeImageDefault(Raster source, WritableRaster dest, Rectangle destRect, javax.media.jai.iterator.RandomIter roiIter, boolean roiContainsTile)
protected void computeImageOptimized(Raster source, WritableRaster dest, Rectangle destRect, javax.media.jai.iterator.RandomIter roiIter, boolean roiContainsTile)
Copyright © 2006–2017 GeoSolutions. All rights reserved.