org.jaitools.media.jai.regionalize
Class RegionalizeDescriptor

java.lang.Object
  extended by javax.media.jai.OperationDescriptorImpl
      extended by org.jaitools.media.jai.regionalize.RegionalizeDescriptor
All Implemented Interfaces:
Serializable, javax.media.jai.OperationDescriptor, javax.media.jai.RegistryElementDescriptor

public class RegionalizeDescriptor
extends javax.media.jai.OperationDescriptorImpl

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| <= tolerance 
where 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

Since:
1.0
Version:
$Id$
Author:
Michael Bedward
See Also:
Serialized Form

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
 
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

REGION_DATA_PROPERTY

public static final 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

See Also:
Constant Field Values
Constructor Detail

RegionalizeDescriptor

public RegionalizeDescriptor()
Constructor.



Copyright © 2009-2013. All Rights Reserved.