javax.media.jai.operator
Class SubsampleBinaryToGrayDescriptor

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

public class SubsampleBinaryToGrayDescriptor
extends OperationDescriptorImpl

An OperationDescriptor describing the "SubsampleBinaryToGray" operation.

The "SubsampleBinaryToGray" operation collects a Binary image pixels into a gray scale image. Roughly speaking, each pixel (x, y) of the destination, is the sum of the source pixel values of the source pixel matrix of size 1/xScale by 1/yScale. In the noninteger case, the next bigger inter is used. Thus when xScale = yScale = 1/2.2, a 3 x 3 pixel matrix into a single destination pixel, resulting in 10 levels [0..9]. The resulting gray values are then normalized to have gray values in [0..255].

The source is a Binary image and the result of the operation is a grayscale image. The scale factors xScale and yScale must be between (0, 1] and strictly bigger than 0.

The destination image is a byte image whose dimensions are:

       dstWidth  = floor(srcWidth * xScale)
       dstHeight = floor(srcHeight * yScale)
 

It may be noted that the minX, minY, width and height hints as specified through the JAI.KEY_IMAGE_LAYOUT hint in the RenderingHints object are not honored, as this operator calculates the destination image bounds itself. The other ImageLayout hints, like tileWidth and tileHeight, however, are honored.

It should be noted that this operation automatically adds a value of Boolean.FALSE for the JAI.KEY_REPLACE_INDEX_COLOR_MODEL to the given configuration since this operation is capable of dealing correctly with a source that has an IndexColorModel, without having to expand the IndexColorModel. This addition will take place only if a value for the JAI.KEY_REPLACE_INDEX_COLOR_MODEL has not already been provided by the user. Note that the configuration Map is cloned before the new hint is added to it.

Specifying a scale factor of greater than 1 or less than 0 will cause an exception. To scale image sizes up or down, see Scale operator.

Resource List
Name Value
GlobalName SubsampleBinaryToGray
LocalName SubsampleBinaryToGray
Vendor com.sun.media.jai
Description Subsamples a binary image into a gray scale image.
DocURL http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/SubsampleBinaryToGrayDescriptor.html
Version 1.0
arg0Desc The X scale factor.
arg1Desc The Y scale factor.

Parameter List
Name Class Type Default Value
xScale java.lang.Float 1.0F
yScale java.lang.Float 1.0F

Since:
JAI 1.1
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
SubsampleBinaryToGrayDescriptor()
          Constructor.
 
Method Summary
static RenderedOp create(RenderedImage source0, Float xScale, Float yScale, RenderingHints hints)
          To subsamples binary image to gray; reverse of dithering.
static RenderableOp createRenderable(RenderableImage source0, Float xScale, Float yScale, RenderingHints hints)
          To subsamples binary image to gray; reverse of dithering.
 Number getParamMinValue(int index)
          Returns the minimum legal value of a specified numeric parameter for this operation.
 PropertyGenerator[] getPropertyGenerators()
          Returns an array of PropertyGenerators implementing property inheritance for the "SubsampleBinaryToGray" operation.
 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, getParamNames, 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

SubsampleBinaryToGrayDescriptor

public SubsampleBinaryToGrayDescriptor()
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)

getPropertyGenerators

public PropertyGenerator[] getPropertyGenerators()
Returns an array of PropertyGenerators implementing property inheritance for the "SubsampleBinaryToGray" operation.

Specified by:
getPropertyGenerators in interface OperationDescriptor
Overrides:
getPropertyGenerators in class OperationDescriptorImpl
Returns:
An array of property generators.
See Also:
OperationDescriptorImpl.getPropertyGenerators(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 "xScale" and "yScale" are both greater than 0 and less than or equal to 1.

The src image must be a binary, a one band, one bit per pixel image with a MultiPixelPackedSampleModel.

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

getParamMinValue

public Number getParamMinValue(int index)
Returns the minimum legal value of a specified numeric parameter for this operation.

For the minimum value of "xScale" and "yScale", this method returns 0. However, the scale factors must be a positive floating number and can not be 0.

Specified by:
getParamMinValue in interface OperationDescriptor
Overrides:
getParamMinValue in class OperationDescriptorImpl
Parameters:
index - The index of the parameter to be queried.
Returns:
A Number representing the minimum legal value, or null if the specified parameter is not numeric.
See Also:
ParameterListDescriptor.getParamValueRange(java.lang.String), ParameterListDescriptor.getEnumeratedParameterValues(java.lang.String), ParameterListDescriptor.isParameterValueValid(java.lang.String, java.lang.Object)

create

public static RenderedOp create(RenderedImage source0,
                                Float xScale,
                                Float yScale,
                                RenderingHints hints)
To subsamples binary image to gray; reverse of dithering.

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

Parameters:
source0 - RenderedImage source 0.
xScale - scaleX must be between 0 and 1, excluding 0. May be null.
yScale - scaleY must be between 0 and 1, excluding 0. 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,
                                            Float xScale,
                                            Float yScale,
                                            RenderingHints hints)
To subsamples binary image to gray; reverse of dithering.

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

Parameters:
source0 - RenderableImage source 0.
xScale - scaleX must be between 0 and 1, excluding 0. May be null.
yScale - scaleY must be between 0 and 1, excluding 0. 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