javax.media.jai.operator
Class SubsampleAverageDescriptor

java.lang.Object
  |
  +--javax.media.jai.OperationDescriptorImpl
        |
        +--javax.media.jai.operator.SubsampleAverageDescriptor
All Implemented Interfaces:
OperationDescriptor, RegistryElementDescriptor, Serializable

public class SubsampleAverageDescriptor
extends OperationDescriptorImpl

An OperationDescriptor describing the "SubsampleAverage" operation. "SubsampleAverage" supports the rendered and renderable modes.

The "SubsampleAverage" operation subsamples an image by averaging over a moving window. The scale factors supplied to the operation are forward mapping coefficients representing the geometric transformation from source to destination image coordinates. For example, if both scale factors were equal to 0.5, the operation would produce an output image of half the size of the input image in both dimensions. Both scale factors must be in the range (0.0, 1.0] or an exception will be thrown when the operation is created. The default value of the vertical scale factor is the value of the horizontal scale factor. If both scale factors equal 1.0, the source image is returned directly.

The size of the moving window or block over which source pixels are averaged varies as a function of the scale factors and is defined as

     int blockX = (int)Math.ceil(1.0/scaleX);
     int blockY = (int)Math.ceil(1.0/scaleY);
 

For a given destination pixel (dstX, dstY), the upper left corner (srcX, srcY) of the source block over which averaging occurs is defined as

     int srcX = (int)Math.floor((dstX - dstMinX)/scaleX + 0.5) + srcMinX;
     int srcY = (int)Math.floor((dstY - dstMinY)/scaleY + 0.5) + srcMinY;
 
where (srcMinX, srcMinY) are the image coordinates of the upper left pixel of the source and (dstMinX, dstMinY) are the image coordinates of the upper left pixel of the destination.

The destination image bounds are defined as

    int dstMinX = (int)Math.floor(srcMinX*scaleX);
    int dstMinY = (int)Math.floor(srcMinY*scaleY);
    int dstWidth = (int)(srcWidth*scaleX);
    int dstHeight = (int)(srcHeight*scaleY);
 
where (srcWidth, srcHeight) and (dstWidth, dstHeight) are the source and destination image dimensions, respectively.

Resource List
Name Value
GlobalName SubsampleAverage
LocalName SubsampleAverage
Vendor com.sun.media.jai
Description Subsamples an image by averaging over a moving window.
DocURL http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/SubsampleAverageDescriptor.html
Version 1.0
arg0Desc The X scale factor.
arg1Desc The Y scale factor.

Parameter List
Name Class Type Default Value
scaleX java.lang.Double 0.5
scaleY java.lang.Double scaleX

Since:
JAI 1.1.2
See Also:
FilteredSubsampleDescriptor, SubsampleBinaryToGrayDescriptor, ScaleDescriptor, Serialized Form

Fields inherited from class javax.media.jai.OperationDescriptorImpl
resources, sourceNames, supportedModes
 
Fields inherited from interface javax.media.jai.OperationDescriptor
NO_PARAMETER_DEFAULT
 
Constructor Summary
SubsampleAverageDescriptor()
          Constructor.
 
Method Summary
static RenderedOp create(RenderedImage source0, Double scaleX, Double scaleY, RenderingHints hints)
          Subsamples an image by averaging over a moving window.
static RenderableOp createRenderable(RenderableImage source0, Double scaleX, Double scaleY, RenderingHints hints)
          Subsamples an image by averaging over a moving window.
 PropertyGenerator[] getPropertyGenerators(String modeName)
          Returns an array of PropertyGenerators implementing property inheritance for the "SubsampleAverage" operation.
protected  boolean validateParameters(String modeName, 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, 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
 

Constructor Detail

SubsampleAverageDescriptor

public SubsampleAverageDescriptor()
Constructor.
Method Detail

getPropertyGenerators

public PropertyGenerator[] getPropertyGenerators(String modeName)
Returns an array of PropertyGenerators implementing property inheritance for the "SubsampleAverage" operation.
Overrides:
getPropertyGenerators in class OperationDescriptorImpl
Following copied from class: javax.media.jai.OperationDescriptorImpl
Parameters:
modeName - the registry mode name
Returns:
An array of PropertyGenerators, or null if this operation does not have any of its own PropertyGenerators.
Throws:
IllegalArgumentException - if modeName is null or if it is not one of the supported modes.
UnsupportedOperationException - if arePropertiesSupported returns false
See Also:
RegistryElementDescriptor

validateParameters

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

In addition to the standard checks performed by the superclass method, this method sets "scaleX" to "scaleY" if the latter is not provided in args.

Overrides:
validateParameters in class OperationDescriptorImpl
Following copied from class: javax.media.jai.OperationDescriptorImpl
Throws:
IllegalArgumentException - if any of the input parameters are null.
See Also:
OperationDescriptorImpl.validateArguments(java.lang.String, java.awt.image.renderable.ParameterBlock, java.lang.StringBuffer), ParameterListDescriptorImpl.isParameterValueValid(java.lang.String, java.lang.Object)

create

public static RenderedOp create(RenderedImage source0,
                                Double scaleX,
                                Double scaleY,
                                RenderingHints hints)
Subsamples an image by averaging over a moving window.

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

Parameters:
source0 - RenderedImage source 0.
scaleX - The X scale factor. May be null.
scaleY - The Y scale factor. 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 scaleX,
                                            Double scaleY,
                                            RenderingHints hints)
Subsamples an image by averaging over a moving window.

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

Parameters:
source0 - RenderableImage source 0.
scaleX - The X scale factor. May be null.
scaleY - The Y scale factor. 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