javax.media.jai.operator
Class SubsampleBinaryToGrayDescriptor

java.lang.Object
  |
  +--javax.media.jai.OperationDescriptorImpl
        |
        +--javax.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.

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.

Note that if your packed binary source image is not tiled, this operation takes the source image size as the default tile size, resulting in possibly a big destination tile for a small image after subsampling. An ImageLayout through RenderingHints can be passed in to save memory usage as follows:

   	// example of using SubsampleBinaryToGray operator
      // src is a RenderedImage

      pb = new ParameterBlock();
      pb.addSource(src);
      pb.add(scaleX);	
      pb.add(scaleY);	
      ImageLayout il = new ImageLayout();
      il.setTileWidth(newTileWidth);
      il.setTileHeight(newTileHeight);
      RenderingHints hints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, il);
      RenderedImage   dst  = (RenderedImage)JAI.create("subsamplebinarytogray",
  	                                                  pb,  hints);
 

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

Fields inherited from class javax.media.jai.OperationDescriptorImpl
resources, sourceNames, supportedModes
 
Constructor Summary
SubsampleBinaryToGrayDescriptor()
          Constructor.
 
Method Summary
 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.
Overrides:
isRenderableSupported in class OperationDescriptorImpl
Tags copied from 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.
Overrides:
getPropertyGenerators in class OperationDescriptorImpl
Returns:
An array of property generators.

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
Tags copied from class: OperationDescriptorImpl
Throws:
IllegalArgumentException - if args is null.
IllegalArgumentException - if msg is null and the validation fails.
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.

Overrides:
getParamMinValue in class OperationDescriptorImpl
Tags copied from 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.
Throws:
IllegalArgumentException - if this operation has no parameters.
ArrayIndexOutOfBoundsException - if there is no parameter corresponding to the specified index.
See Also:
ParameterListDescriptor.getParamValueRange(java.lang.String), ParameterListDescriptor.getEnumeratedParameterValues(java.lang.String), ParameterListDescriptor.isParameterValueValid(java.lang.String, java.lang.Object)