How to deblur an image in frequency domain?

조회 수: 19 (최근 30일)
irem oz
irem oz 2022년 1월 6일
댓글: Bjorn Gustavsson 2022년 1월 6일
Hi, I've blurred an image by using averaging filter mask in frequency domain. Now, I want to deblur it but I keep getting a black image. Here is my code:
*1161x799 is the size of my image
I want to know why I keep getting a black image even if I use another trustworthy code.
im_gray = rgb2gray(im);
im_gray = im2double(im_gray);
%17*17 Average Filter
avgFilter = ones(17) / 289;
%Now taking FFT of both image and filter to work in frequency domain
im_fft = fft2(im_gray, 1161,799);
avgFilter_fft = fft2(avgFilter, 1161,799);
Conv = im_fft .* avgFilter_fft;
%inverse FFT
blurry_image = ifft2(Conv);
%deblur
Inv = Conv./avgFilter_fft;
deblur = ifft2(Inv);

채택된 답변

Bjorn Gustavsson
Bjorn Gustavsson 2022년 1월 6일
Most likely you have a problem with division-by-zero in the:
Inv = Conv./avgFilter_fft;
step. If you try to set those components of Inv to zero and then proceed you might have your problem solved:
Inv = Conv./avgFilter_fft;
Inv(~isfinite(Inv(:))) = 0;
That circumvented your problem when I tested. For real cases you will obviously use some more sensible damping of the deconvolution-step, perhaps something like:
Inv = conj(avgFilter_fft).*Conv./(abs(avgFilter_fft).^2+damping_delta);
Or something more fancy depending on the wavenumber amplitudes to some power.
HTH
  댓글 수: 2
irem oz
irem oz 2022년 1월 6일
Thank you very much. It worked properly.
Bjorn Gustavsson
Bjorn Gustavsson 2022년 1월 6일
My pleasure.

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by