public final class PaintOpImage
extends javax.media.jai.PointOpImage
This class implements a convolution operation. Convolution is a spatial operation that computes each output sample by multiplying elements of a kernel with the samples surrounding a particular source sample.
For each destination sample, the kernel is rotated 180 degrees and its "key element" is placed over the source pixel corresponding with the destination pixel. The kernel elements are multiplied with the source pixels under them, and the resulting products are summed together to produce the destination sample value.
Example code for the convolution operation on a single sample dst[x][y] is as follows. First your original kernel is rotated by 180 degrees, then the following - assuming the kernel is of size M rows x N columns and the rotated kernel's key element is at position (xKey, yKey):
dst[x][y] = 0; for (int i = -xKey; i < M - xKey; i++) { for (int j = -yKey; j < N - yKey; j++) { dst[x][y] += src[x + i][y + j] * kernel[xKey + i][yKey + j]; } }
Convolution, or any neighborhood operation, leaves a band of pixels around the edges undefined, i.e., for a 3x3 kernel, only four kernel elements and four source pixels contribute to the destination pixel located at (0,0). Such pixels are not includined in the destination image. A BorderOpImage may be used to add an appropriate border to the source image in order to avoid shrinkage of the image boundaries.
The Kernel cannot be bigger in any dimension than the image data.
KernelJAI
Constructor and Description |
---|
PaintOpImage(RenderedImage source0,
RenderedImage source1,
Map config,
javax.media.jai.ImageLayout layout,
Color paintColor,
boolean alphaIsFirst)
Creates a ConvolveOpImage given a ParameterBlock containing the image
source and pre-rotated convolution kernel.
|
Modifier and Type | Method and Description |
---|---|
protected void |
computeRect(Raster[] sources,
WritableRaster dest,
Rectangle destRect)
Performs convolution on a specified rectangle.
|
computeTile, dispose, isColormapOperation, mapDestRect, mapSourceRect, permitInPlaceOperation
addTileToCache, cancelTiles, computeRect, computesUniqueTiles, createTile, getExpandedNumBands, getFormatTags, getOperationComputeType, getTile, getTileCache, getTileCacheMetric, getTileDependencies, 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 PaintOpImage(RenderedImage source0, RenderedImage source1, Map config, javax.media.jai.ImageLayout layout, Color paintColor, boolean alphaIsFirst)
source0
- a sourcesource1
- a alpha mask for paintingconfig
- the image configuration.layout
- an ImageLayout optionally containing the tile grid layout,
SampleModel, and ColorModel, or null.paintColor
- The paint color.alphaIsFirst
- Whether alpha is the first bandprotected void computeRect(Raster[] sources, WritableRaster dest, Rectangle destRect)
computeRect
in class javax.media.jai.OpImage
sources
- an array of source Rasters, guaranteed to provide all
necessary source data for computing the output.dest
- a WritableRaster tile containing the area to be computed.destRect
- the rectangle within dest to be processed.Copyright © 2014–2017 European Space Agency (ESA). All rights reserved.