All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Class java.awt.image.ThresholdOp

java.lang.Object
    |
    +----java.awt.image.ThresholdOp

public class ThresholdOp
extends Object
implements BufferedImageOp, RasterOp
This class performs thresholding on the source image by mapping the value of each image component (for BufferedImages) or channel element (for Rasters) that falls between a low and a high value, to a constant.

For Rasters, the number of sets of threshold constants may be one, in which case the same constants are applied to all bands, or it must equal the number of Source Raster bands.

For BufferedImages, the number of low/high values may be one, in which case the same range is applied to all color and alpha components, or it must equal the number of Source color components, in which case no thresholding of the alpha component (if present) is performed, or it must equal the number of Source color components plus alpha components, in which case all color and alpha components are thresholded. Image with an IndexColorModel cannot be thresholded.

The pseudo code for the thresholding operation is as follows:

for each pixel from Source object {
    for each channel/component of the pixel {
        if (srcElement <= thresholdValue) {
            destElement = lowValue;
        }
        else {
            destElement = highValue;
        }
    }
}
 
Note that in-place operation is allowed (i.e. the source and destination can be the same object).


Constructor Index

 o ThresholdOp(int, int, int)
Constructs a new ThresholdOp with the desired mapping.
 o ThresholdOp(int[], int[], int[])
Constructs a new ThresholdOp with the desired per channel/component mappings.

Method Index

 o createCompatibleDestImage(BufferedImage, ColorModel)
Creates an empty destination image with the correct size and number of bands.
 o createCompatibleDestRaster(Raster)
Creates an empty destination Raster with the correct size and number of bands.
 o filter(BufferedImage, BufferedImage)
Performs thresholding on the BufferedImage.
 o filter(Raster, WritableRaster)
Performs thresholding on the Raster.
 o getDestBounds(BufferedImage)
Returns the bounding box of the thresholded destination.
 o getDestBounds(Raster)
Returns the bounding box of the thresholded destination.
 o getDestPoint(Point2D, Point2D)
Returns the location of the destination point given a point in the source image.
 o getHighs()
Returns the high value array.
 o getLows()
Returns the low value array.
 o getThreshold()
Returns the threshold value.

Constructors

 o ThresholdOp
public ThresholdOp(int[] threshold,
                   int[] low,
                   int[] high)
Constructs a new ThresholdOp with the desired per channel/component mappings. The number of sets of mapping constants is subject to the restrictions given in the class comments above.

 o ThresholdOp
public ThresholdOp(int threshold,
                   int low,
                   int high)
Constructs a new ThresholdOp with the desired mapping. The same set of thresholding constants will be applied to all channels/components of the Raster/BufferedImage.

Methods

 o getThreshold
public final int[] getThreshold()
Returns the threshold value.

 o getLows
public final int[] getLows()
Returns the low value array.

 o getHighs
public final int[] getHighs()
Returns the high value array.

 o filter
public BufferedImage filter(BufferedImage src,
                            BufferedImage dst)
Performs thresholding on the BufferedImage. If the color model in the source image is not the same as that in the destination image, the pixels will be converted in the destination. If the destination image is null, a BufferedImage will be created with the source ColorModel. The number of sets of threshold constants in this object may be one, in which case the same constants are applied to all color and alpha components, or it must equal the number of Source color components, in which case no thresholding of the alpha component (if present) is performed, or it must equal the number of Source color components plus alpha components, in which case all color and alpha components are thresholded. Otherwise an IllegalArgumentException will be thrown.

 o filter
public WritableRaster filter(Raster src,
                             WritableRaster dst)
Performs thresholding on the Raster. If the destination Raster is null, a new Raster will be created. The source and destination must have the same number of bands. The number of sets of threshold constants in this object may be one, in which case the same constants are applied to all bands, or it must equal the number of Source Raster bands. An IllegalArgumentException will be thrown if the number of bands in the source does not match the destination, or if the above restrictions on the number of sets of threshold constants are not met.

 o getDestBounds
public Rectangle2D getDestBounds(BufferedImage src)
Returns the bounding box of the thresholded destination. Since this is not a geometric operation, the bounding box does not change. An IllegalArgumentException will be thrown if the number of sets of threshold constants does not meet the restrictions stated in the class comments above.

 o getDestBounds
public Rectangle2D getDestBounds(Raster src)
Returns the bounding box of the thresholded destination. Since this is not a geometric operation, the bounding box does not change. An IllegalArgumentException will be thrown if the number of sets of threshold constants does not meet the restrictions stated in the class comments above.

 o createCompatibleDestImage
public BufferedImage createCompatibleDestImage(BufferedImage src,
                                               ColorModel destCM)
Creates an empty destination image with the correct size and number of bands. An IllegalArgumentException will be thrown if the number of sets of threshold constants does not meet the restrictions stated in the class comments above.

Parameters:
src - Source image for the filter operation.
destCM - ColorModel of the destination. If null, the ColorModel of the source will be used.
 o createCompatibleDestRaster
public WritableRaster createCompatibleDestRaster(Raster src)
Creates an empty destination Raster with the correct size and number of bands. An IllegalArgumentException will be thrown if the number of sets of threshold constants does not meet the restrictions stated in the class comments above.

 o getDestPoint
public Point2D getDestPoint(Point2D srcPt,
                            Point2D dstPt)
Returns the location of the destination point given a point in the source image. If dstPt is non-null, it will be used to hold the return value. Since this is not a geometric operation, the srcPt will equal the dstPt.


All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Submit a bug or feature