3

Gauss filter is a famous image denoising tool in image processing domain. I saw lots of opensource software choose the template like this:

enter image description here

Where do these value come from?

Mailerdaimon
  • 6,003
  • 3
  • 35
  • 46
tidy
  • 4,747
  • 9
  • 49
  • 89

2 Answers2

5

You linked the Answer yourself. These values are a discrete representation of the Gaussian Function.

The 2D Gaussian looks like this:

enter image description here

To get the Filter Values you evaluate the 2D-Gaussian Function at the discrete x-y Position corresponding to your Kernel Size and sigma.

On this website you can find a detailed explanation of the Gaussian Filter.

Mailerdaimon
  • 6,003
  • 3
  • 35
  • 46
  • But the value at (0,0) of G(x,y) is 0.159, not 41. Thanks for you link, I'll study it. – tidy Nov 18 '13 at 11:33
  • 2
    The Value in your Matrix is not 41! It is 41 divided by 273. This is important! Another point is that the Kernel can be scaled such that the value of the edges is one (divided by 273). – Mailerdaimon Nov 18 '13 at 12:01
2

That is an approximation of a Gaussian filter called Binomial Filter. You can see the difference here: http://www.cse.yorku.ca/~kosta/CompVis_Notes/binomial_filters.pdf.old

If you want to get a discrete Gaussian filter you can see this video https://www.youtube.com/watch?v=3z3GDUFR4Lw

So, for example, if you want a Gaussian filter 3x3 with standard deviation σ = 1.

From 2D Gaussian:

2D gaussian equation

If matrix dimension is 3x3 (nxn), then the coefficient k is 1, (because the gaussian function goes -k,..., 0, ..., k, in this case: -1, 0, 1, and that's why the dimension is 3)

So, you have to calculate the matrix like this:

Gaussian matrix 3x3

The solution will be:

Gaussian matrix 3x3 result

Note that there's no even dimension since the matrix dimension is depending on n = 2k+1, which refer to odd numbers.

bad_coder
  • 11,289
  • 20
  • 44
  • 72