Image Processing in C#: Part 7 - Applying a Gaussian Blur
Gaussian blur also uses convolution to create the effect. If you have not yet read my blog post on smoothing using convolution, I would advise you to read that post first, as in that post I explain how the convolution function works.
Gaussian blur works very similarly to the smoothing function, in that both are a type of blur, but the Gaussian blur gives a more natural looking blur. It achieves this by not have a flat weighting, but instead has a weighting based on a Gaussian curve, thus for our 3x3 grid, the values we want to supply the convolution function is as follows:
1 | 2 | 1 |
2 | 4 | 2 |
1 | 2 | 1 |
The factor parameter is set to the sum of each pixel in the grid, which in this case, is again, 16, and the offset is set to 0.
Now we will get a nice blur effect.
The full source used in the series is available from https://github.com/sjmeunier/image-processor.
Originally posted on my old blog, Smoky Cogs, on 19 Nov 2009