What do fspecial image filtering parameters mean?

조회 수: 1 (최근 30일)
Chad Greene
Chad Greene 2014년 9월 8일
댓글: Chad Greene 2014년 9월 9일
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?

채택된 답변

David Young
David Young 2014년 9월 9일
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
Chad Greene
Chad Greene 2014년 9월 9일
David, thank you so much for this clear explanation. It all makes sense now.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by