
the square-r oot function, which boosts midrange colors more than colors that are
dark or bright:
byte[] data = new byte[256];
for(int i = 0; i < 256; i++)
data[i] = (byte)(Math.sqrt((float)i/255.0) * 255);
ByteLookupTable table = new ByteLookupTable(0, data);
LookupOp op = new LookupOp(table, null);
BufferedImage brighterImage = op.filter(sourceImage, null);
You can blur an image using a ConvolveOp. When processing an image by convo-
lution, a pixel value in the destination image is computed from the corresponding
pixel value in the source image and the pixels that surround that pixel. A matrix of
numbers known as the ker nel is used to specify the contribution of each source
pixel to the destination pixel. To per form a simple blurring operation, you might
use a kernel like this to specify that the destination pixel is the average of the
source pixel and the eight pixels that surround that source pixel:
0.1111 0.1111 0.1111
0.1111 0.1111 0.1111
0.1111 0.1111 0.1111
Note that the sum of the values in this kernel is 1.0, which means that the destina-
tion image has the same brightness as the source image. To per form a simple blur,
use code like this:
Kernel k = new Kernel(3, 3, new float[] { .1111f, .1111f, .1111f,
.1111f, .1111f, .1111f,
.1111f, .1111f, .1111f });
ConvolveOp op = new ConvolveOp(k);
BufferedImage blurry = op.filter(sourceImage, null);
Tr ansfor mations with AffineTransfor m
As we discussed ...