Home > Tutorials > Image Processing – Gaussian Blur

Image Processing – Gaussian Blur


One of very famous algorithm for blurry effect is “Gaussian Blur”.

It uses the concepts of Convolution Filtering to apply in image processing.

You might need to refer to my previous article on Convolution Matrix.

The matrix used in Gaussian Blur is

[ 1 – 2 – 1]

[ 2 – 4 – 2]

[ 1 – 2 – 1]

The factor is 16 and with offset 0.

Compared these two pixes:

Original Image

Original Image

Applied Gaussian Blur

Applied Gaussian Blur

Look carefully you can see the blurred one is a little smaller than the original, that’s because of size a little bit change (not much different) while applying matrix computation.

Here the implementation:

	public static Bitmap applyGaussianBlur(Bitmap src) {
		double[][] GaussianBlurConfig = new double[][] {
			{ 1, 2, 1 },
			{ 2, 4, 2 },
			{ 1, 2, 1 }
		};
		ConvolutionMatrix convMatrix = new ConvolutionMatrix(3);
		convMatrix.applyConfig(GaussianBlurConfig);
		convMatrix.Factor = 16;
		convMatrix.Offset = 0;
		return ConvolutionMatrix.computeConvolution3x3(src, convMatrix);
	}

Not so hard to understand, is it?

 

You can find more references about blurry effect over Internet. I won’t talk about them here!

 

Hope you like it!

Cheers,
Pete Houston

  1. AlpeshDG
    March 30, 2013 at 5:00 pm

    how to blur image on seekbar change in android

  2. October 23, 2012 at 6:47 pm

    how to blur a image at specific point of the image?? any idea?

  3. October 23, 2012 at 6:46 pm

    how to blur a specific point of the image.. any idea??

  4. asd
    May 9, 2012 at 9:18 pm

    Hi,
    How what parameters i need to change to make the picture more blurry?

    Thanks !

    • Noe Rodriguez
      June 15, 2012 at 12:17 am

      Actually if you repeat the same process a lot of times, each time it’s gonna be more blurry. The unique problem: time.

  5. Junior
    June 22, 2011 at 9:58 pm

    and if you want to achieve the emboss effect… try this:

    ConvolutionMatrix matrix = new ConvolutionMatrix(3);
    double config[][] = {{-1,0,-1},{0,4,0},{-1,0,-1}};
    matrix.applyConfig(config);
    matrix.Factor = 1;
    matrix.Offset = 127;

  6. Junior
    June 22, 2011 at 9:57 pm

    got a great effect using {{-1,0,-1},{0,4,0},{-1,0,-1}}; as config, Factor and Offset are the same! Thanks

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: