javax.media.jai.operator
Class ConvolveDescriptor
java.lang.Object
|
+--javax.media.jai.OperationDescriptorImpl
|
+--javax.media.jai.operator.ConvolveDescriptor
- All Implemented Interfaces:
- OperationDescriptor, RegistryElementDescriptor, Serializable
- public class ConvolveDescriptor
- extends OperationDescriptorImpl
An 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.
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.
Resource List
Name | Value |
GlobalName | Convolve |
LocalName | Convolve |
Vendor | com.sun.media.jai |
Description | Performs kernel-based convolution
on an image. |
DocURL | http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/ConvolveDescriptor.html |
Version | 1.0 |
arg0Desc | The convolution kernel. |
Parameter List
Name | Class Type |
Default Value |
kernel | javax.media.jai.KernelJAI |
NO_PARAMETER_DEFAULT |
- See Also:
OperationDescriptor
,
KernelJAI
, Serialized Form
Methods inherited from class javax.media.jai.OperationDescriptorImpl |
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 |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ConvolveDescriptor
public ConvolveDescriptor()
- Constructor.
getPropertyGenerators
public PropertyGenerator[] getPropertyGenerators()
- Returns an array of
PropertyGenerators
implementing
property inheritance for the "Convolve" operation.
- Overrides:
getPropertyGenerators
in class OperationDescriptorImpl
- Returns:
- An array of property generators.
create
public static RenderedOp create(RenderedImage source0,
KernelJAI kernel,
RenderingHints hints)
- Performs kernel-based convolution on an image.
Creates a ParameterBlockJAI
from all
supplied arguments except hints
and invokes
JAI.create(String,ParameterBlock,RenderingHints)
.
- Parameters:
source0
- RenderedImage
source 0.kernel
- The convolution kernel.hints
- The RenderingHints
to use.
May be null
.- Returns:
- The
RenderedOp
destination. - Throws:
IllegalArgumentException
- if source0
is null
.IllegalArgumentException
- if kernel
is null
.- See Also:
JAI
,
ParameterBlockJAI
,
RenderedOp