public class MaskedConvolveDescriptor
extends javax.media.jai.OperationDescriptorImpl
convolve operator by providing
the option to select which source and or destination pixels are included in processing
using an associated ROI object.
Two masking options are provided:
With this operator, a given destination pixel will have a nil result if any of the following are true:
minCells parameter).
nilValue
parameter (the default is 0).
You can specify the minimum number of non-zero kernel cells that must be positioned over
unmasked source image pixels for convolution to be performed via the minCells
parameter. If there are NO_DATA values defined (see nodata parameter below) then
this parameter refers to the number of unmasked source image pixels with data.
Any of the following are accepted:
Number with value between one and the number of non-zero kernel cells (inclusive).
String representing a numeric value.
RenderedImage img = ...
float[] kernelData = new float[]{ // for neighbourhood sum
0, 0, 1, 0, 0,
0, 1, 1, 1, 0,
1, 1, 1, 1, 1,
0, 1, 1, 1, 0,
0, 0, 1, 0, 0,
};
KernelJAI kernel = new KernelJAI(5, 5, kernelData);
ROI roi = new ROI(img, thresholdValue);
ParameterBlockJAI pb = new ParameterBlockJAI("maskedconvolve");
pb.setSource("source0", op0);
pb.setParameter("kernel", kernel);
pb.setParameter("roi", roi);
pb.setParameter("nilValue", Integer.valueOf(-1));
// no need to set masksource and maskdest params if we want to
// use their default values (TRUE)
BorderExtender extender = BorderExtender.createInstance(BorderExtender.BORDER_ZERO);
RenderingHints hints = new RenderingHints(JAI.KEY_BORDER_EXTENDER, extender);
RenderedOp dest = JAI.create("maskedconvolve", pb, hints);
Summary of parameters:
| Name | Class | Default | Description |
|---|---|---|---|
| kernel | KernelJAI | No default | Kernel defining the convolution neighbourhood |
| roi | ROI | No default | ROI to use for source and/or destination masking |
| maskSource | Boolean | true | Whether to apply source masking |
| maskDest | Boolean | true | Whether to apply destination masking |
| nilValue | Number | 0 | Value to return for pixels with no convolution result |
| minCells | See note above | MIN_CELLS_ANY | Minimun number of non-zero kernel cells over unmasked source image pixels for convolution to be performed |
| nodata | Collection | null |
Values to be treated as NO_DATA. A value can be either a Number or a
Range (mixtures of both are permitted).
|
| strictNodata | Boolean | false |
If true, convolution will no be performed for a target pixel with
any NODATA values in its neighbourhood (non-zero kernel cells); if false
convolution can occur, subject to masking and minCells criteria, with
NODATA values being ignored.
|
KernelFactory,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
static Number |
DEFAULT_NIL_VALUE
Default value for nilValue parameter (0)
|
static String |
MIN_CELLS_ALL
Constant that can be used for the minCells parameter to require
all non-zero kernel cells to overlap with unmasked source image
cells for convolution to be performed for a terget cell
|
static String |
MIN_CELLS_ANY
Constant that can be used for the minCells parameter to specify
convolution will be performed for a terget cell if any non-zero kernel
cells overlap with unmasked source image cells.
|
| Constructor and Description |
|---|
MaskedConvolveDescriptor()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
validateParameters(String modeName,
ParameterBlock pb,
StringBuffer msg)
Validates the supplied parameters.
|
arePropertiesSupported, getDefaultSourceClass, getDestClass, getDestClass, getInvalidRegion, getName, getNumParameters, getNumSources, getParamClasses, getParamDefaults, getParamDefaultValue, getParameterListDescriptor, getParamMaxValue, getParamMinValue, getParamNames, getPropertyGenerators, getPropertyGenerators, getRenderableDestClass, getRenderableSourceClasses, getResourceBundle, getResources, getSourceClasses, getSourceClasses, getSourceNames, getSupportedModes, isImmediate, isModeSupported, isRenderableSupported, isRenderedSupported, makeDefaultSourceClassList, validateArguments, validateArguments, validateParameters, validateRenderableArguments, validateRenderableSources, validateSources, validateSourcespublic static final String MIN_CELLS_ANY
public static final String MIN_CELLS_ALL
public static final Number DEFAULT_NIL_VALUE
protected boolean validateParameters(String modeName, ParameterBlock pb, StringBuffer msg)
validateParameters in class javax.media.jai.OperationDescriptorImplmodeName - the rendering modepb - the input parametersmsg - a StringBuffer instance to receive error messagestrue if parameters are valid; false otherwiseCopyright © 2009–2020. All rights reserved.