public class ConvolveDescriptor
extends javax.media.jai.OperationDescriptorImpl
OperationDescriptor
describing the "Convolve" 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," or origin, is placed over the source pixel corresponding with the destination pixel. The kernel elements are multiplied with the source pixels beneath them, and the resulting products are summed together to produce the destination sample value.
This operation is able to check if each input pixel is contained inside the provided ROI and if it is not a NoData value. If a pixel in the kernel is outside ROI or a NoData, the related Kernel value is not calculated and destination No Data value is returned.
Pseudocode for the convolution operation on a single sample dst[x][y] is as follows, assuming the kernel is of size width x height and has already been rotated through 180 degrees. The kernel's Origin element is located at position (xOrigin, yOrigin):
dst[x][y] = 0; for (int i = -xOrigin; i < -xOrigin + width; i++) { for (int j = -yOrigin; j < -yOrigin + height; j++) { dst[x][y] += src[x + i][y + j] * kernel[xOrigin + i][yOrigin + j]; } }
Convolution, like any neighborhood operation, leaves a band of pixels around the edges undefined. For example, for a 3x3 kernel only four kernel elements and four source pixels contribute to the convolution pixel at the corners of the source image. Pixels that do not allow the full kernel to be applied to the source are not included in the destination image. A "Border" operation may be used to add an appropriate border to the source image in order to avoid shrinkage of the image boundaries.
The kernel may not be bigger in any dimension than the image data.
It should be noted that this operation automatically adds a value of Boolean.TRUE
for the
JAI.KEY_REPLACE_INDEX_COLOR_MODEL
to the given configuration
so that the operation is performed on the pixel values
instead of being performed on the indices into the color map if the source(s) have an IndexColorModel
. This addition will take place
only if a value for the JAI.KEY_REPLACE_INDEX_COLOR_MODEL
has not already been provided by the user. Note that the
configuration
Map is cloned before the new hint is added to it. The operation can be smart about the value of the
JAI.KEY_REPLACE_INDEX_COLOR_MODEL
RenderingHints
, i.e. while the default value for the
JAI.KEY_REPLACE_INDEX_COLOR_MODEL
is Boolean.TRUE
, in some cases the operator could set the default.
Name | Value |
---|---|
GlobalName | Convolve |
LocalName | Convolve |
Vendor | it.geosolutions.jaiext |
Description | Convolves the source image with the input kernel. |
DocURL | http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/ConvolveDescriptor.html |
Version | 1.0 |
arg0Desc | Input convolution kernel. |
arg1Desc | Optional ROI object to use in computation. |
arg2Desc | Optional Range of NoData values to use in computation. |
arg3Desc | Destination No Data value used when the computation cannot be performed. |
arg4Desc | Boolean indicating if kernels with NoData must be skipped from computation. |
Name | Class Type | Default Value |
---|---|---|
kernel | javax.media.jai.KernelJAI | NO_PARAMETER_DEFAULT |
roi | javax.media.jai.ROI | null |
nodata | it.geosolutions.jaiext.range.Range | null |
destNoData | Double | 0 |
skipNoData | Boolean | true |
Constructor and Description |
---|
ConvolveDescriptor()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static javax.media.jai.RenderedOp |
create(RenderedImage source0,
javax.media.jai.KernelJAI kernel,
javax.media.jai.ROI roi,
Range nodata,
double destNoData,
boolean skipNoData,
RenderingHints hints)
Performs kernel-based convolution on an image.
|
javax.media.jai.PropertyGenerator[] |
getPropertyGenerators()
Returns an array of
PropertyGenerators implementing property inheritance for the "Convolve" operation. |
arePropertiesSupported, getDefaultSourceClass, getDestClass, getDestClass, getInvalidRegion, getName, getNumParameters, getNumSources, getParamClasses, getParamDefaults, getParamDefaultValue, getParameterListDescriptor, getParamMaxValue, getParamMinValue, getParamNames, getPropertyGenerators, getRenderableDestClass, getRenderableSourceClasses, getResourceBundle, getResources, getSourceClasses, getSourceClasses, getSourceNames, getSupportedModes, isImmediate, isModeSupported, isRenderableSupported, isRenderedSupported, makeDefaultSourceClassList, validateArguments, validateArguments, validateParameters, validateParameters, validateRenderableArguments, validateRenderableSources, validateSources, validateSources
public javax.media.jai.PropertyGenerator[] getPropertyGenerators()
PropertyGenerators
implementing property inheritance for the "Convolve" operation.getPropertyGenerators
in interface javax.media.jai.OperationDescriptor
getPropertyGenerators
in class javax.media.jai.OperationDescriptorImpl
public static javax.media.jai.RenderedOp create(RenderedImage source0, javax.media.jai.KernelJAI kernel, javax.media.jai.ROI roi, Range nodata, double destNoData, boolean skipNoData, RenderingHints hints)
Creates a ParameterBlockJAI
from all supplied arguments except hints
and invokes
JAI.create(String,ParameterBlock,RenderingHints)
.
source0
- RenderedImage
source 0.kernel
- The convolution kernel.roi
- Optional ROI to use in computationnodata
- Optional nodata Range to check for NoDatadestNoData
- Double value used for setting destination No Data value when it is not possible to
calculate the convolved resultskipNoData
- Boolean indicating if kernels with NoData must be skipped from computationhints
- The RenderingHints
to use. May be null
.RenderedOp
destination.IllegalArgumentException
- if source0
is null
.IllegalArgumentException
- if kernel
is null
.JAI
,
ParameterBlockJAI
,
RenderedOp
Copyright © 2006–2015 GeoSolutions. All rights reserved.