
% function to smooth an image be averaging over adjacent 
% squares

function    newimage= smooth(image)
   [L,K] =size(image)
   newimage=zeros(L,K);
   for l=2:L-1
      for k=2:K-1
	   newimage(l,k)= (image(l,k)+...
	                  image(l+1,k)+...
	                  image(l+1,k+1)+...
	                  image(l,k+1)+...
	                  image(l-1,k+1)+...
	                  image(l-1,k)+...
	                  image(l-1,k-1)+...
	                  image(l,k-1)+...
	                  image(l+1,k-1)...
			  )/9;
      end 
   end % for l
   figure
   imshow(uint8(image))
   figure
   imshow(uint8(newimage))
return
