If the user clicks the Brighten button, Graphicizer brightens the image, as you can see in Figure 3.6. Figure 3.6. Brightening an image.To brighten an image, you simply multiply the intensity of each pixel. In this case, all you need is a one-dimensional kernel. Here's what the code looks like, complete with Kernel and ConvolveOp objects: if(event.getSource() == button3){ bufferedImageBackup = bufferedImage; Kernel kernel = new Kernel(1, 1, new float[] {3}); ConvolveOp convolveOp = new ConvolveOp(kernel); BufferedImage temp = new BufferedImage( bufferedImage.getWidth(), bufferedImage.getHeight(), BufferedImage.TYPE_INT_ARGB); convolveOp.filter(bufferedImage, temp); bufferedImage = temp; repaint(); } That completes the brightening operationnow you can lighten any image with just the click of a button. |