|
Hi all,
I try to restore the degraded image with full inverse filter, but I got NAN values, so the restored image is just a white blank image. I am new, and this is my first time to ask for help here. Thanks in advance!
The link for the origianl image is http://users.rowan.edu/~shreek/fall09/dip/lab3/GW_Fig5_26.jpg
blew is the code:
f=imread('GW_Fig5_26.jpg');
figure;
imshow(mat2gray(double(f)));
title('original image')
S=size(f);
F=fftshift(fft2(f));
T=1;
a=0.1;
b=0.1;
%b=0;
c_x=floor(S(1)/2);
c_y=floor(S(2)/2);
H=zeros(S);
%construct the blurred image by planar motion model
for m=1:S(1)
for n=1:S(2)
v=m-c_x;
u=n-c_y;
temp=pi*(u*a+v*b);
if (temp~=0)
H(m,n)=T/temp*sin(temp)*exp(-temp*1i);
end
end
end
G=H.*F;
g=abs(ifft2(fftshift(G)));
figure;
imshow(mat2gray(g));
title('2-D planar motion blurred image');
level=1;
gn=g+sqrt(650*level)*randn(688,688);
figure;
imshow(mat2gray(double(gn)));
title('2-D planar motion blurred image and with noise added');
%restore the image with full inverse filtering
GN=abs(fftshift(fft2(gn)));
F_restored=GN./double(H);
f_restored=abs(ifft2(fftshift(F_restored)))
figure;
imshow(mat2gray(f_restored));
title('restored image with full inverse filtering');
|