Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine the window size of a Gaussian filter

Gaussian smoothing is a common image processing function, and for an introduction of Gaussian filtering, please refer to here. As we can see, one parameter: standard derivation will determine the shape of Gaussian function. However, when we perform convolution with Gaussian filtering, another parameter: the window size of Gaussian filter should also be determined at the same time. For example, when we use fspecial function provided by MATLAB, not only the standard derivation but also the window size must be provided. Intuitively, the larger the Gaussian standard derivation is the bigger the Gaussian kernel window should. However, there is no general rule about how to set the right window size. Any ideas? Thanks!

like image 328
feelfree Avatar asked Apr 23 '13 09:04

feelfree


2 Answers

The size of the mask drives the filter amount. A larger size, corresponding to a larger convolution mask, will generally result in a greater degree of filtering. As a kinda trade-off for greater amounts of noise reduction, larger filters also affect the details quality of the image.

That's as milestone. Now coming to the Gaussian filter, the standard deviation is the main parameter. If you use a 2D filter, at the edge of the mask you will probably desire the weights to approximate 0.

To this respect, as I already said, you can choose a mask with a size which is generally three times the standard deviation. This way, almost the whole Gaussian bell is taken into account and at the mask's edges your weights will asymptotically tend to zero.

I hope this helps.

like image 105
fpe Avatar answered Sep 18 '22 13:09

fpe


Here is a good reference.

  1. After discretizing, pixel with distance greater than 3 sigma have negligible weights. See this

  2. As already pointed, 6sigma, implies 3sigma both ways

  3. Size of convolution matrix to be used for filtering would inadvertently be 6sigma by 6sigma, because of points 1 and 2 above.

Here how you can obtain the discrete Gaussian.

Finally, the size of the standard deviation(and therefore the Kernel used) depends on how much noise you suspect to be in the image. Clearly, a larger convolution kernel implies farther pixels get to contribute to the new value of the centre pixel as opposed to a smaller kernel.

like image 38
I L Avatar answered Sep 22 '22 13:09

I L