Class ContourDescriptor

  extended by
      extended by
All Implemented Interfaces:

public class ContourDescriptor

Describes the "Contour" operation in which contour lines are interpolated from values in a source image band. The desired contour values can be specified either by supplying a Collection of values via the "levels" parameter, or a single value via the "interval" parameter. In the interval case, the resulting contour values will be integer multiples of the interval. If both parameters are supplied the "levels" parameter takes preference.

Contours are returned as a destination image property in the form of a Collection of LineString objects. The source image value associated with each contour can be retrieved with the Geometry.getUserData() method.

Source image pixels are passed through to the destination image unchanged.

Three boolean parameters control the form of the generated contours:

  1. simplify: if true (the default) colinear vertices are removed to reduce contour memory requirements.
  2. mergeTiles: if true (the default) contour lines are merged into LineStrings across image tile boundaries; if false mergine is skipped for faster processing.
  3. smooth: if true contours are smoothed using Bezier interpolation before being returned; if false (the default) no smoothing is done. This option will probably have little effect on the form of contours unless the source image resolution is coarse.
Example of use:

 RenderedImage src = ...
 ParameterBlockJAI pb = new ParameterBlockJAI("Contour");
 pb.setSource("source0", src);
 // For contours at specific levels set the levels parameter
 List<Double> levels = Arrays.asList(new double[]{1.0, 5.0, 10.0, 20.0, 50.0, 100.0});
 pb.setParameter("levels", levels);
 // Alternatively, set a constant interval between contours
 pb.setParameter("interval", 10.0);
 RenderedOp dest = JAI.create("Contour", pb);
 Collection<LineString> contours = (Collection<LineString>) 
 for (LineString contour : contours) {
   // get this contour's value
   Double contourValue = (Double) contour.getUserData();
The interpolation algorithm used is that of Paul Bourke: originally published in Byte magazine (1987) as the CONREC contouring subroutine written in FORTRAN. The implementation here was adapted from Paul Bourke's C code for the algorithm available at:

Summary of parameters:

Name Class Default Description
roi ROI null An optional ROI defining the area to contour.
band Integer 0 Source image band to process.
levels Collection null The values for which to generate contours.
interval Number null The interval between contour values. This parameter is ignored if the levels parameter has been supplied. With interval contouring the minimum and maximum contour values will be integer multiples of the interval parameter value.
nodata Collection The set: {Double.NaN, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.MAX_VALUE} Values to be treated as NO_DATA. A value can be either a Number or a Range (mixtures of both are permitted).
strictNodata Boolean Boolean.TRUE If true, any NODATA values in the 2x2 cell moving window used by the contouring algorithm will cause that part of the image to be skipped. If false, a single NODATA value will be permitted in the window. This probably only makes a noticeable difference with small images.
simplify Boolean Boolean.TRUE Whether to simplify contour lines by removing collinear vertices.
smooth Boolean Boolean.FALSE Whether to smooth contour lines using Bezier interpolation. This probably only makes a noticeable difference with small images.

Michael Bedward
See Also:
Serialized Form

Field Summary
          Constant identifying the image property that will hold the generated contours.
Fields inherited from class
resources, sourceNames, supportedModes
Fields inherited from interface
Constructor Summary
          Creates a new instance.
Method Summary
protected  boolean validateParameters(String modeName, ParameterBlock pb, StringBuffer msg)
          Validates supplied parameters.
Methods inherited from class
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, 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 CONTOUR_PROPERTY_NAME
Constant identifying the image property that will hold the generated contours.

See Also:
Constant Field Values
Constructor Detail


public ContourDescriptor()
Creates a new instance.

Method Detail


protected boolean validateParameters(String modeName,
                                     ParameterBlock pb,
                                     StringBuffer msg)
Validates supplied parameters.

validateParameters in class
modeName - the rendering mode
pb - the parameter block
msg - a StringBuffer to receive error messages
true if parameters are valid; false otherwise

Copyright © 2009-2013. All Rights Reserved.