Gaussian blur and convolution kernels

ExtremeCoder picture ExtremeCoder · Jul 29, 2010 · Viewed 22.7k times · Source

I do not understand what a convolution kernel is and how I would apply a convolution matrix to pixels in an image (I am talking about doing a Gaussian Blur operation on an image).

Also could I get an explanation on how to create a kernel for a Gaussian Blur operation?

I am reading this article but I cannot seem to understand how things are done...

Thanks to anyone who takes time to explain this to me :),

ExtremeCoder

Answer

Jonathan Fischoff picture Jonathan Fischoff · Jul 29, 2010

The basic idea is that the new pixels of the image are created by an weighted average of the pixels close to it (imagine drawing a circle around the pixel).

For each pixel in the image you are going to create a little square around the pixel. Lets say you take the 8 neighbors next to a pixel (including diagonals even though do not matter here), and we perform a weighted average to get the middle pixel.

In the Gaussian blur case it breaks down to two one dimensional operations. For each pixel take the some amount of pixels next to a pixel in the row direction only. Multiply the pixel values time the weights computed from the Gaussian distribution (or if you are doing this for an visual effect and not for a scientific reason, the weights can anything that looks good) and sum them up. Another way to look at it is the pixel make a vector and the weights make a vector and your are taking the dot product. Repeat this process in the column direction as a separate pass.