javax.media.jai.operator
Class ClampDescriptor

java.lang.Object
  extended byjavax.media.jai.OperationDescriptorImpl
      extended byjavax.media.jai.operator.ClampDescriptor
All Implemented Interfaces:
OperationDescriptor, RegistryElementDescriptor, Serializable

public class ClampDescriptor
extends OperationDescriptorImpl

An OperationDescriptor describing the "Clamp" operation.

The Clamp operation takes one rendered or renderable source image, and sets all the pixels whose value is below a "low" value to that low value and all the pixels whose value is above a "high" value to that high value. The pixels whose value is between the "low" value and the "high" value are left unchanged.

A different set of "low" and "high" values may be applied to each band of the source image, or the same set of "low" and "high" values may be applied to all bands of the source. If the number of "low" and "high" values supplied is less than the number of bands of the source, then the values from entry 0 are applied to all the bands. Each "low" value must be less than or equal to its corresponding "high" value.

The destination pixel values are defined by the pseudocode:

 lowVal = (low.length < dstNumBands) ?
          low[0] : low[b];
 highVal = (high.length < dstNumBands) ?
           high[0] : high[b];

 if (src[x][y][b] < lowVal) {
     dst[x][y][b] = lowVal;
 } else if (src[x][y][b] > highVal) {
     dst[x][y][b] = highVal;
 } else {
     dst[x][y][b] = src[x][y][b];
 }
 

Resource List
Name Value
GlobalName Clamp
LocalName Clamp
Vendor com.sun.media.jai
Description Clamps the pixel values of an image to a specified range.
DocURL http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/ClampDescriptor.html
Version 1.0
arg0Desc The lower boundary for each band.
arg1Desc The upper boundary for each band.

Parameter List
Name Class Type Default Value
low double[] {0.0}
high double[] {255.0}

See Also:
OperationDescriptor, Serialized Form

Field Summary
 
Fields inherited from class javax.media.jai.OperationDescriptorImpl
sourceNames, supportedModes
 
Fields inherited from interface javax.media.jai.OperationDescriptor
NO_PARAMETER_DEFAULT
 
Constructor Summary
ClampDescriptor()
          Constructor.
 
Method Summary
static RenderedOp create(RenderedImage source0, double[] low, double[] high, RenderingHints hints)
          Clamps the pixel values of an image to a specified range.
static RenderableOp createRenderable(RenderableImage source0, double[] low, double[] high, RenderingHints hints)
          Clamps the pixel values of an image to a specified range.
 boolean isRenderableSupported()
          Returns true since renderable operation is supported.
protected  boolean validateParameters(ParameterBlock args, StringBuffer msg)
          Validates the input parameters.
 
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, 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
 

Constructor Detail

ClampDescriptor

public ClampDescriptor()
Constructor.

Method Detail

isRenderableSupported

public boolean isRenderableSupported()
Returns true since renderable operation is supported.

Specified by:
isRenderableSupported in interface OperationDescriptor
Overrides:
isRenderableSupported in class OperationDescriptorImpl
See Also:
OperationDescriptorImpl.isModeSupported(java.lang.String)

validateParameters

protected boolean validateParameters(ParameterBlock args,
                                     StringBuffer msg)
Validates the input parameters.

In addition to the standard checks performed by the superclass method, this method checks that "low" and "high" have length at least 1 and that each "low" value is less than or equal to the corresponding "high" value.

Overrides:
validateParameters in class OperationDescriptorImpl
See Also:
OperationDescriptorImpl.validateParameters(java.lang.String, java.awt.image.renderable.ParameterBlock, java.lang.StringBuffer)

create

public static RenderedOp create(RenderedImage source0,
                                double[] low,
                                double[] high,
                                RenderingHints hints)
Clamps the pixel values of an image to a specified range.

Creates a ParameterBlockJAI from all supplied arguments except hints and invokes JAI.create(String,ParameterBlock,RenderingHints).

Parameters:
source0 - RenderedImage source 0.
low - The lower boundary for each band. May be null.
high - The upper boundary for each band. May be null.
hints - The RenderingHints to use. May be null.
Returns:
The RenderedOp destination.
Throws:
IllegalArgumentException - if source0 is null.
See Also:
JAI, ParameterBlockJAI, RenderedOp

createRenderable

public static RenderableOp createRenderable(RenderableImage source0,
                                            double[] low,
                                            double[] high,
                                            RenderingHints hints)
Clamps the pixel values of an image to a specified range.

Creates a ParameterBlockJAI from all supplied arguments except hints and invokes JAI.createRenderable(String,ParameterBlock,RenderingHints).

Parameters:
source0 - RenderableImage source 0.
low - The lower boundary for each band. May be null.
high - The upper boundary for each band. May be null.
hints - The RenderingHints to use. May be null.
Returns:
The RenderableOp destination.
Throws:
IllegalArgumentException - if source0 is null.
See Also:
JAI, ParameterBlockJAI, RenderableOp