Wiener filter image restoration

%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?

Respuestas (1)

Image Analyst
Image Analyst el 3 de Oct. de 2020
Try imshow() with [] instead:
subplot(1,2,2); % Display in the right hand axes.
imshow(abs(I_recon), []);

6 comentarios

Kat_33
Kat_33 el 3 de Oct. de 2020
I did try that before, it doesnt solve my problem unfortunately
Image Analyst
Image Analyst el 3 de Oct. de 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
Kat_33 el 3 de Oct. de 2020
As I said, I'm not getting anything that looks like the reconstructed image, its simply noise without any trace of the original picture
Image Analyst
Image Analyst el 4 de Oct. de 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
Kat_33 el 4 de Oct. de 2020
But I didn't apply any filter to blur the image. It is already blurred and I'm trying to unblur it using the wiener formula as I wrote it above(without using deconvwnr), not sure why its not working
Image Analyst
Image Analyst el 4 de Oct. de 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.

Iniciar sesión para comentar.

Categorías

Más información sobre Read, Write, and Modify Image en Centro de ayuda y File Exchange.

Preguntada:

el 3 de Oct. de 2020

Comentada:

el 4 de Oct. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by