%Question No: 9
%Take a grayscale image. Add Gaussian noise to it. Write a MATLAB function
%for implementing the L-R (Lucy-Richardson) algorithm with different 
%iterations for image restoration.

function gaussianLR(z)
f=imread(z);
[m n]=size(f);
f=im2double(f);
h=fspecial('gaussian',7,10);
g=imfilter(f,h,'circular');
it=input('Enter the number of iterations : ');
   a=0.1;
   b=0.01;
   r=a+b*randn(m,n);
   g=g+r;
   D=0.1*b;
   c=g;
 
  for i=1:it
  s=imfilter(c,h,'conv','circular');
  t=g./(s+eps);
  u=imfilter(t,h,'corr','circular');
  w=c.*u;
  x=abs(g-w);
  c(x>D)=w(x>D);
  end
figure,imshow(f),title('Original Image');
figure,imshow(g),title('Gaussian Noise Image');
figure,imshow(c),title('Reconstructed Image');

