%lee filter for speckle noise reduction
%Usage - improve_lee(I)
%I is the noisy image (gray level image m x n x 1)
function lee=improve_lee(I)
[x y z]=size(I);
%I=double(I);
for i=1:x
%i
for j=1:y
% Checking first and last pixel of first row%
if (i==1 & j==1)
mat(1)=0;
mat(2)=0;
mat(3)=0;
mat(4)=0;
mat(5)=I(i,j);
mat(6)=I(i,j+1);
mat(7)=0;
mat(8)=I(i+1,j);
mat(9)=I(i+1,j+1);
end
if (i==1 & j==y)
mat(1)=0;
mat(2)=0;
mat(3)=0;
mat(4)=I(i,j-1);
mat(5)=I(i,j);
mat(6)=0;
mat(7)=I(i+1,j-1);
mat(8)=I(i+1,j);
mat(9)=0;
end
% Checking first and last pixel of last row%
if (i==x & j==1)
mat(1)=0;
mat(2)=I(i-1,j);
mat(3)=I(i-1,j+1);
mat(4)=0;
mat(5)=I(i,j);
mat(6)=I(i,j+1);
mat(7)=0;