You can also use Graphicizer to blur an image by clicking the Blur button. You can see the results in Figure 3.7, where the image has an out-of-focus look. Figure 3.7. Blurring an image.To blur an image, the code will simply combine the pixels surrounding a particular pixel. Here's what this looks like using a Kernel object and a ConvolveOp object: if(event.getSource() == button4){ bufferedImageBackup = bufferedImage; Kernel kernel = new Kernel(3, 3, new float[] {.25f, 0, .25f, 0, 0, 0, .25f, 0, .25f}); ConvolveOp convolveOp = new ConvolveOp(kernel); BufferedImage temp = new BufferedImage( bufferedImage.getWidth(), bufferedImage.getHeight(), BufferedImage.TYPE_INT_ARGB); convolveOp.filter(bufferedImage, temp); bufferedImage = temp; repaint(); } And that's all it takesnow you can blur images just by clicking the Blur button. |