Digital Image Processing
Digital Image Processing
Digital Image Processing
Assignment#2
Image Restoration
(Wiener Filtering)
By:
SUGUMAR.D,
RESULT-1
Input Image Blur Function
Blurred Output Image Filtered Output Image
(Gama=.00001)
RESULT-2 RESULT-3
Filtered Output Image Filtered Output Image
(Gama=.01) (Gama=.045)
RESULT-4 RESULT-5
Filtered Output Image Filtered Output Image
(Gama=.45) (Gama=1)
Program:
clc;clear all;close all;
%--------Image Restoration-wiener filtering-------------%
%getting the input image
f2=imread('enamel.tif');
f1=imresize(f2,[256 256]);
f=im2double(f1);[l m]=size(f);F=fft2(f);
%--------------------------------------------------------------%
%degrading the image with Blurring and AGWN
%blurring the input image using the fun with a=b=.001,T=1
a=.001;b=.001;T=1;
for u=1:1:l
for v=1:1:m
H(u,v)=(T/(3.14*(u*a+v*b)))*(sin(3.14*(u*a+v*b)))*(exp(-j*3.14*(u*a+v*b)));
blu(u,v)=F(u,v)*H(u,v);
end
end
c1=ifft2(blu);
imwrite(c1,'rew.tif');
r1=imread('rew.tif');
r2=im2double(r1);
%--------------------------------------------------------------%
subplot (2,2,1);
imshow(f);
title('Input Image');
subplot (2,2,2);
imshow(H);
title('Blur Function');
subplot (2,2,3);
imshow(c1);
title('Blur Output');
G=fft2(c1);
%--------------------------------------------------------------%
% Image Restoration-wiener filtering
% =========================================================%
gama=.045;
for u=1:1:l
for v=1:1:m
F1(u,v)=(1/H(u,v))*((abs(H(u,v)))^2)/((abs(H(u,v)))^2+gama)*G(u,v);
end
end
fr=ifft2(F1);
subplot (2,2,4);
imshow(fr);
title('output image');