# How to deconvolve an image in MATLAB? i was using weiner filter for this purpose but didn't get the results.

조회 수: 1(최근 30일)
Shoaib Ul Hassan 2020년 3월 2일
댓글: Gab D 2020년 8월 6일
function ex = wienerFilter(y,h,sigma,gamma,alpha);
%
% ex = wienerFilter(y,h,sigma,gamma,alpha);
%
% Generalized Wiener filter using parameter alpha. When
% alpha = 1, it is the Wiener filter. It is also called
% Regularized inverse filter.
%
% Reference: Richb's paper
% Created: Tue May 4 16:24:06 CDT 1999, Huipin Zhang
N = size(y,1);
Yf = fft2(y);
Hf = fft2(h,N,N);
Pyf = abs(Yf).^2/N^2;
% direct implementation of the regularized inverse filter,
% when alpha = 1, it is the Wiener filter
% Gf = conj(Hf).*Pxf./(abs(Hf.^2).*Pxf+alpha*sigma^2);
%
% Since we don't know Pxf, the following
% handle singular case (zero case)
sHf = Hf.*(abs(Hf)>0)+1/gamma*(abs(Hf)==0);
iHf = 1./sHf;
iHf = iHf.*(abs(Hf)*gamma>1)+gamma*abs(sHf).*iHf.*(abs(sHf)*gamma<=1);
Pyf = Pyf.*(Pyf>sigma^2)+sigma^2*(Pyf<=sigma^2);
Gf = iHf.*(Pyf-sigma^2)./(Pyf-(1-alpha)*sigma^2);
% max(max(abs(Gf).^2)) % should be equal to gamma^2
% Restorated image without denoising
eXf = Gf.*Yf;
ex = real(ifft2(eXf));
return
##### 댓글 수: 1표시숨기기 없음
Gab D 2020년 8월 6일
Hi, could you provide de full reference of Richb's paper? I am not able to determine what is the gamma variable.
Also, since we dont know Pxf, could we just use an approximation based on a standart Fourier deconvolution X_0hat=Y/H and compute Pxf from there?
Thank you in advance for your help!

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

### 답변(1개)

Daniel Vieira 2020년 3월 2일
Looking superficially this code seems right, would have to go through the theory to check. But you can also use the function wiener2.
##### 댓글 수: 1표시숨기기 없음
Shoaib Ul Hassan 2020년 3월 3일
And what if i want to use Blind Deconvolution Method?

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

### Community Treasure Hunt

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

Start Hunting!