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.
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 ...
Get Java 2D Graphics now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.