|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavax.media.jai.OperationDescriptorImpl
org.jaitools.media.jai.regionalize.RegionalizeDescriptor
public class RegionalizeDescriptor
Describes the "Regionalize" operation.
This operation takes a single source image and identifies regions of connected pixels with uniform value, where value comparisons take into account a user-specified tolerance.
Note: At present, this operator only deals with a single band.
Algorithm
The operator scans the source image left to right, top to bottom. When
it reaches a pixel that has not been allocated to a region yet it uses
that pixel as the starting point for a flood-fill search (similar to
flood-filling in a paint program). The value of the starting pixel is
recorded as the reference value for the new region. The search works
its way outwards from the starting pixel, testing other pixels for
inclusion in the region. A pixel will be included if:
|value - reference value| <= tolerancewhere tolerance is a user-specified parameter.
If the diagonal parameter is set to true, the flood-fill search will include pixels that can only be reached via a diagonal step; if false, only orthogonal steps are taken.
The search continues until no further pixels can be added to the region. The region is then allocated a unique integer ID and summary statistics (bounds, number of pixels, reference value) are recorded for it.
The output of the operation is an image of data type TYPE_INT, where each pixel's value is its region ID. A RegionData object can be retrieved as a property of the output image using the property name REGION_DATA_PROPERTY).
Example
RenderedImage myImg = ...
ParameterBlockJAI pb = new ParameterBlockJAI("regionalize");
pb.setSource("source0", myImg);
pb.setParameter("band", 0);
pb.setParameter("tolerance", 0.1d);
pb.setParameter("diagonal", false);
RenderedOp regionImg = JAI.create("Regionalize", pb);
// have a look at the image (this will force rendering and
// the calculation of region data)
// print the summary data
RegionData regData =
(RegionData)op.getProperty(RegionalizeDescriptor.REGION_DATA_PROPERTY);
List<Region> regions = regData.getData();
Iterator<Region> iter = regions.iterator();
System.out.println("ID\tValue\tSize\tMin X\tMax X\tMin Y\tMax Y");
while (iter.hasNext()) {
Region r = iter.next();
System.out.println( String.format("%d\t%.2f\t%d\t%d\t%d\t%d\t%d",
r.getId(),
r.getRefValue(),
r.getNumPixels(),
r.getMinX(),
r.getMaxX(),
r.getMinY(),
r.getMaxY() ));
Summary of parameters:
| Name | Class | Default | Description |
|---|---|---|---|
| band | int | 0 | The source image band to process |
| tolerance | double | 0 | Tolerance for comparison of image values |
| diagonal | boolean | false |
If true diagonal connections are allowed; if false
only orthogonal connections are allowed
|
| Field Summary | |
|---|---|
static String |
REGION_DATA_PROPERTY
The propoerty name to retrieve the RegionData object which holds summary data for regions identified in the source image and depicted in the destination image |
| Fields inherited from class javax.media.jai.OperationDescriptorImpl |
|---|
resources, sourceNames, supportedModes |
| Fields inherited from interface javax.media.jai.OperationDescriptor |
|---|
NO_PARAMETER_DEFAULT |
| Constructor Summary | |
|---|---|
RegionalizeDescriptor()
Constructor. |
|
| Method Summary | |
|---|---|
static javax.media.jai.RenderedOp |
create(RenderedImage source0,
int band,
double tolerance,
boolean diagonal,
RenderingHints hints)
Deprecated. This method will be removed in JAITools version 1.3 |
| Methods inherited from class javax.media.jai.OperationDescriptorImpl |
|---|
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, validateParameters, validateRenderableArguments, validateRenderableSources, validateSources, validateSources |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String REGION_DATA_PROPERTY
| Constructor Detail |
|---|
public RegionalizeDescriptor()
| Method Detail |
|---|
public static javax.media.jai.RenderedOp create(RenderedImage source0,
int band,
double tolerance,
boolean diagonal,
RenderingHints hints)
ParameterBlockJAI and
invokes JAI.create("regionalize", params) .
If an ImageLayout object is included in the RenderingHints passed to
this method, any specification of the SampleModel for the destination
image will be overridden such that the destination will always be
TYPE_INT.
source0 - the image to be regionalizedband - the band to processtolerance - tolerance for pixel value comparisonsdiagonal - true to include diagonal connections; false for only
orthogonal connectionshints - rendering hints (may be null)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||