Wiener filter image restoration
Afficher commentaires plus anciens
%parameter T (observation time) and motion rate
T=1; ax=30; ay=40; NSR=0; %since no noise
%reading the blurred picture
I=im2double(imread('blur.bmp'));
%generating frequencies for the blurring model
u=linspace(-0.5,0.5,size(I,2));
v=linspace(-0.5,0.5,size(I,1));
[U,V]=meshgrid(u,v);
H=(T./(pi*(U*ax+V*ay))).*sin(pi*(U*ax+V*ay)).*exp(-1i*pi*(U*ax+V*ay));
I_f=fft2(I);
I_motion_fn=fftshift(I_f);
wiener=(1./H).*((H.^2)./((H.^2)+NSR));
I_recon_fn=I_motion_fn.*wiener;
I_recon=ifft2(ifftshift(I_recon_fn));
figure(1);
subplot(1,2,1), imagesc(I), colormap(gray)
title('original image')
subplot(1,2,2),imagesc(abs(I_recon))
title('reconstruction using wiener')
Im trying to restore the following image using a wiener filter as show above, however im not getting the reconstructed image, what is the issue? I know that a wiener filter with no noise acts like an ideal inverse filter, however applying the code above is not showing me the reconstructed image

Also, if I were to do the same code but using the built in deconvwnr filter, how would I go around that using the parameters I have?
Réponses (1)
Image Analyst
le 3 Oct 2020
Try imshow() with [] instead:
subplot(1,2,2); % Display in the right hand axes.
imshow(abs(I_recon), []);
6 commentaires
Kat_33
le 3 Oct 2020
Image Analyst
le 3 Oct 2020
Why do you say you can't get I_recon? Does the fft2() or ifftshift() not work or throw an error or something? It's not just going to finish with no I_recon being created unless an error is thrown. Do you see I_recon in the workspace? Do you see any red error text (that you forgot to attach)? Please reply after you read this link.
Or do you actually get I_recon (contrary to what you said), but you just don't like how it looks?
Kat_33
le 3 Oct 2020
Image Analyst
le 4 Oct 2020
Then I guess you didn't pick the correct inverse filter - the same one used to blur the image in the first place.
Kat_33
le 4 Oct 2020
Image Analyst
le 4 Oct 2020
Rather than starting out with some image where you don't know the blur kernel, start out with a known image, and then blur it with a known kernel. Then use that to see how well you can undo the blur using the known kernel.
Catégories
En savoir plus sur Deblurring dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!