How to deblur an image in frequency domain?
5 views (last 30 days)
Show older comments
irem oz
on 6 Jan 2022
Commented: Bjorn Gustavsson
on 6 Jan 2022
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);
0 Comments
Accepted Answer
Bjorn Gustavsson
on 6 Jan 2022
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
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!