Java BufferedImage Blur generateBlurImage(BufferedImage image)

Here you can find the source of generateBlurImage(BufferedImage image)

Description

Generate Blur Image.

License

Open Source License

Parameter

Parameter Description
image input image.

Declaration

public static BufferedImage generateBlurImage(BufferedImage image) 

Method Source Code

//package com.java2s;
/**/*www  .  j  a  v a 2 s. c  o m*/
 * Copyright 2014 Comcast Cable Communications Management, LLC
 *
 * This file is part of CATS.
 *
 * CATS is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * CATS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with CATS.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.awt.image.BufferedImage;
import java.awt.image.ConvolveOp;
import java.awt.image.Kernel;

public class Main {
    /**
     * Generate Blur Image.
     * 
     * @param image
     *            input image.
     */
    public static BufferedImage generateBlurImage(BufferedImage image) {
        float[] blurelement = { 1f / 9f, 1f / 9f, 1f / 9f, 1f / 9f, 1f / 7f, 1f / 9f, 1f / 9f, 1f / 9f, 1f / 9f // blur
                                                                                                                // Kernel
        };

        Kernel blurKernel = new Kernel(3, 3, blurelement);
        ConvolveOp simpleBlur = new ConvolveOp(blurKernel, ConvolveOp.EDGE_NO_OP, null);// EDGE_NO_OP,
                                                                                        // null);
        image = simpleBlur.filter(image, null); // blur the image
        return image;
    }
}

Related

  1. applySimpleBoxBlur(final BufferedImage sourceImage)