MATLAB Answers

How to use wiener filter?

22 views (last 30 days)
Im really new with matlab and image processing, so i follow some journal how to do wiener filter and im using this code to blur the image:
LEN1 = 15; % Panjang blur (satuan: pixel)
THETA1 = 15; % sudut blur (satuan: derajat)
PSF1 = fspecial('motion', LEN1, THETA1);
Blurred1 = imfilter(I, PSF1, 'conv', 'circular');
and this is the code to do the wiener filter:
wnr1 = deconvwnr(Blurred1, PSF1);
But, the result is different from the journal that i saw, this is the blured version:
and this is fixed version, after the wiener filter code:
Is this the correct result?i think im doing it wrong, i dont this is the correct result
If im doing it wrong, what should i add or change?
Thank you

  0 Comments

Sign in to comment.

Accepted Answer

Bjorn Gustavsson
Bjorn Gustavsson on 12 Jun 2020
If you read the help for deconwnr you see that there is a third input, NSR, for the image Noise-to-Signal-Ratio. Since the Wiener-deconvolution is a high-frequency-amplifying operation. If you look at the code in deconvwnr you will see how the deconvolution is done in the Fourier-domain:
% Compute the Wiener restoration filter:
%
% H*(k,l)
% G(k,l) = ------------------------------
% |H(k,l)|^2 + S_u(k,l)/S_x(k,l)
%
% where S_u is the signal power spectrum and S_x is the noise power
% spectrum.
%
% To minimize issues associated with divisions, the equation form actually
% implemented here is this:
%
% H*(k,l) S_x(k,l)
% G(k,l) = ------------------------------
% |H(k,l)|^2 S_x(k,l) + S_u(k,l)
%
Where H is the Fourier-transform of your PSF and S_u and S_xis the noise-power and image-power respectively (that get handled resp estimated by deconvwnr). If you dont send in a noise-level it seems deconvwnr assumes that power to be zero, which leads to noise-amplification (H^*/|H|^2 will grow towards infinity where |H| goes to zero - which it will do for high frequencies). Since you're working with finite precision this will manifest as amplification of the highest frequencies - where discretisation-noise will be amplified. Try to send in some noise-levels to deconvwnr to see how that reduces this effect.
HTH

  2 Comments

Ibrahim Musa Adi
Ibrahim Musa Adi on 12 Jun 2020
It works! i add one more parameter to the deconvwnr it so much better!
Thank you so much!
Bjorn Gustavsson
Bjorn Gustavsson on 12 Jun 2020
My pleasure.

Sign in to comment.

More Answers (0)