Top Description Fields Constructors Methods
java.awt.image

public Class BandCombineOp

extends Object
implements RasterOp
Class Inheritance
All Implemented Interfaces
java.awt.image.RasterOp
Imports
java.awt.GraphicsEnvironment, .Rectangle, .RenderingHints, java.awt.color.ICC_Profile, java.awt.geom.Rectangle2D, .Point2D, sun.awt.image.ImagingLib, java.util.Arrays

This class performs an arbitrary linear combination of the bands in a Raster, using a specified matrix.

The width of the matrix must be equal to the number of bands in the source Raster, optionally plus one. If there is one more column in the matrix than the number of bands, there is an implied 1 at the end of the vector of band samples representing a pixel. The height of the matrix must be equal to the number of bands in the destination.

For example, a 3-banded Raster might have the following transformation applied to each pixel in order to invert the second band of the Raster.

  [ 1.0   0.0   0.0    0.0  ]     [ b1 ]
  [ 0.0  -1.0   0.0  255.0  ]  x  [ b2 ]
  [ 0.0   0.0   1.0    0.0  ]     [ b3 ]
                                  [ 1 ]

Note that the source and destination can be the same object.

Field Summary

Modifier and TypeField and Description
pack-priv RenderingHints
pack-priv float[][]
pack-priv int
pack-priv int

Constructor Summary

AccessConstructor and Description
public
BandCombineOp(float[][]
The matrix to use for the band combine operation.
matrix
,
RenderingHints
The RenderingHints object for this operation. Not currently used so it can be null.
hints
)

Constructs a BandCombineOp with the specified matrix.

Method Summary

Modifier and TypeMethod and Description
public WritableRaster

Returns:

The zeroed destination Raster.
createCompatibleDestRaster
(Raster
The Raster to be filtered.
src
)

Implements java.awt.image.RasterOp.createCompatibleDestRaster.

Creates a zeroed destination Raster with the correct size and number of bands.
public WritableRaster

Returns:

The filtered Raster.
filter
(Raster
The Raster to be filtered.
src
,
WritableRaster
The Raster in which to store the results of the filter operation.
dst
)

Implements java.awt.image.RasterOp.filter.

Transforms the Raster using the matrix specified in the constructor.
public final Rectangle2D

Returns:

The Rectangle2D representing the destination image's bounding box.
getBounds2D
(Raster
The Raster to be filtered.
src
)

Implements java.awt.image.RasterOp.getBounds2D.

Returns the bounding box of the transformed destination.
public final float[][]

Returns:

The matrix associated with this band combine operation.
getMatrix
()

Returns a copy of the linear combination matrix.

public final Point2D

Returns:

The Point2D in the destination image that corresponds to the specified point in the source image.
getPoint2D
(Point2D
The Point2D that represents the point in the source Raster
srcPt
,
Point2D
The Point2D in which to store the result.
dstPt
)

Implements java.awt.image.RasterOp.getPoint2D.

Returns the location of the corresponding destination point given a point in the source Raster.
public final RenderingHints

Returns:

The RenderingHints object associated with this operation. Returns null if no hints have been set.
getRenderingHints
()

Implements java.awt.image.RasterOp.getRenderingHints.

Returns the rendering hints for this operation.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

hintsback to summary
pack-priv RenderingHints hints
matrixback to summary
pack-priv float[][] matrix
ncolsback to summary
pack-priv int ncols
nrowsback to summary
pack-priv int nrows

Constructor Detail

BandCombineOpback to summary
public BandCombineOp(float[][] matrix, RenderingHints hints)

Constructs a BandCombineOp with the specified matrix. The width of the matrix must be equal to the number of bands in the source Raster, optionally plus one. If there is one more column in the matrix than the number of bands, there is an implied 1 at the end of the vector of band samples representing a pixel. The height of the matrix must be equal to the number of bands in the destination.

The first subscript is the row index and the second is the column index. This operation uses none of the currently defined rendering hints; the RenderingHints argument can be null.

Parameters
matrix:float[][]

The matrix to use for the band combine operation.

hints:RenderingHints

The RenderingHints object for this operation. Not currently used so it can be null.

Method Detail

createCompatibleDestRasterback to summary
public WritableRaster createCompatibleDestRaster(Raster src)

Implements java.awt.image.RasterOp.createCompatibleDestRaster.

Creates a zeroed destination Raster with the correct size and number of bands. An IllegalArgumentException may be thrown if the number of bands in the source is incompatible with the matrix. See the class comments for more details.

Parameters
src:Raster

The Raster to be filtered.

Returns:WritableRaster

The zeroed destination Raster.

filterback to summary
public WritableRaster filter(Raster src, WritableRaster dst)

Implements java.awt.image.RasterOp.filter.

Transforms the Raster using the matrix specified in the constructor. An IllegalArgumentException may be thrown if the number of bands in the source or destination is incompatible with the matrix. See the class comments for more details.

If the destination is null, it will be created with a number of bands equalling the number of rows in the matrix. No exception is thrown if the operation causes a data overflow.

Parameters
src:Raster

The Raster to be filtered.

dst:WritableRaster

The Raster in which to store the results of the filter operation.

Returns:WritableRaster

The filtered Raster.

Exceptions
IllegalArgumentException:
If the number of bands in the source or destination is incompatible with the matrix.
getBounds2Dback to summary
public final Rectangle2D getBounds2D(Raster src)

Implements java.awt.image.RasterOp.getBounds2D.

Returns the bounding box of the transformed destination. Since this is not a geometric operation, the bounding box is the same for the source and destination. An IllegalArgumentException may be thrown if the number of bands in the source is incompatible with the matrix. See the class comments for more details.

Parameters
src:Raster

The Raster to be filtered.

Returns:Rectangle2D

The Rectangle2D representing the destination image's bounding box.

Exceptions
IllegalArgumentException:
If the number of bands in the source is incompatible with the matrix.
getMatrixback to summary
public final float[][] getMatrix()

Returns a copy of the linear combination matrix.

Returns:float[][]

The matrix associated with this band combine operation.

getPoint2Dback to summary
public final Point2D getPoint2D(Point2D srcPt, Point2D dstPt)

Implements java.awt.image.RasterOp.getPoint2D.

Returns the location of the corresponding destination point given a point in the source Raster. If dstPt is specified, it is used to hold the return value. Since this is not a geometric operation, the point returned is the same as the specified srcPt.

Parameters
srcPt:Point2D

The Point2D that represents the point in the source Raster

dstPt:Point2D

The Point2D in which to store the result.

Returns:Point2D

The Point2D in the destination image that corresponds to the specified point in the source image.

getRenderingHintsback to summary
public final RenderingHints getRenderingHints()

Implements java.awt.image.RasterOp.getRenderingHints.

Returns the rendering hints for this operation.

Returns:RenderingHints

The RenderingHints object associated with this operation. Returns null if no hints have been set.