O'Reilly logo

Java 2D Graphics by Jonathan Knudsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

10.3. Predefined Operations

The 2D API comes complete with a handful of useful image operators. These are implementations of the BufferedImageOp interface. Table 10-1 summarizes the image operator classes that are defined in java.awt.image. I'll talk about each type of operator in the coming sections. The "In Place?" column indicates whether the operator is capable of in-place processing, where the source and destination image are the same.

Table 10-1. Image Processing Classes
Class Name Supporting Classes Effect In Place?
ConvolveOp Kernel blurring, sharpening, edge detection no
AffineTransformOp java.awt.geom.AffineTransform geometric transformation no
LookupOp LookupTable, ByteLookupTable, ShortLookupTable posterizing, inversion yes
RescaleOp  brightening, darkening yes
ColorConvertOp java.awt.color.ColorSpace color space conversion yes

10.3.1. Blurring and Sharpening

ConvolveOp is one of the most versatile image operators in the 2D API. It represents a spatial convolution, which is a fancy mathematical term that means that the color of each destination pixel is determined by combining the colors of the corresponding source pixel and its neighbors. A convolution operator can be used to blur or sharpen an image, among other things.

10.3.1.1. Kernels

The convolution operator uses a kernel to specify how a source pixel and its neighbors are combined. A kernel is simply a matrix, where the center of the matrix represents the source pixel and the other elements correspond ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required