What do fspecial image filtering parameters mean?

2 vues (au cours des 30 derniers jours)
Chad Greene
Chad Greene le 8 Sep 2014
Commenté : Chad Greene le 9 Sep 2014
I would like to high-pass-filter an image to get rid of wavelengths longer than about 30 pixels. Here is what I am trying:
hpFiltImage = myImage - imfilter(myImage,fspecial('gaussian',hsize,sigma));
I do not have an intuition for the units or meaning of hsize and sigma. How do I choose hsize and sigma to get the desired cutoff wavelength of 30 pixels?

Réponse acceptée

David Young
David Young le 9 Sep 2014
The Gaussian filter does not have a sharp cut-off, but 2*pi*sigma is the wavelength at which the amplitude is multiplied by a factor of about 0.6 (more exactly, exp(-0.5)). So you might set sigma to 30/(2*pi) to suppress wavelengths over about 30 pixels.
hsize needs to be big enough that you don't truncate the filter too much. I use hsize = 2*ceil(2.6*sigma)+1 which gives roughly 1% truncation error on each dimension of the image, but you may wish to vary this depending on the trade-off between precision and compute time for your problem.
  1 commentaire
Chad Greene
Chad Greene le 9 Sep 2014
David, thank you so much for this clear explanation. It all makes sense now.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by