Archive

Posts Tagged ‘gaussian’

Image Processing – Gaussian Blur

June 22, 2011 7 comments

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