The Java 2D API provides a framework for filtering images. That
is, a source image enters a filter, the filter processes the image
data in some way, and a new image emerges.
Source Image ==> Filter ==> Destination
Image
The java.awt.image
package includes several filter classes and you can also create
your own. The filter classes implement the java.awt.image.BufferedImageOp
interface. This interface holds five methods but the crucial one
is
public
BufferedImage filter (BufferedImage sourceImg, BufferedImage destImg)
This method will act upon (but not change) the source image and
will return the processed version as the destination image. If the
destImg
argument is not null, then the filter will use this image object
to hold the processed image. If it is null, then the filter will
create a new image object. In some, but not all filters, the source
and destination images can be the same. (This is referred to as
in-place filtering.)
The five filtering classes provide with the java.awt.image
package include:
- ConvolveOP
convolution filter that applies a given kernel operator to the
image data for effects such as edge detection, sharpening, and
other effects.
- AffineTransformOp
affine transforms, such as translation, scaling, flipping, rotation,
and shearing, map 2D structures in one space to another space
while maintaining straight lines and the parallelism in the original
image.
- LookupOp
instances of LookupTable are used to map source pixels to destination
pixels according to the pixel component values (cant be used
with indexed color model images). Provides color transformation
effects such as the inversion of gray scales.
- RescaleOp
apply a scaling factor to the color components so as to brighten
or dim an image.
- ColorConvertOp
change to a different color space such as converting a color
image to a grey scale image.
We discuss each of these in the following sections.
References & Web Resources
Latest update: April 17, 2005
|