Brightening an Image

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.

    Java After Hours(c) 10 Projects You'll Never Do at Work
    Java After Hours: 10 Projects Youll Never Do at Work
    ISBN: 0672327473
    EAN: 2147483647
    Year: 2006
    Pages: 128 © 2008-2017.
    If you may any questions please contact us: