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

%function    newimage= smooth(image)
close all;
   read_rose;
   image= Rose_image;
   [L,K] =size(image);
   image=int32(image);
   newimage=zeros(L,K);
   figure
   imshow(uint8(image));
   for iter=1:101
      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
      if mod(iter,10)==1
         figure
         imshow(uint8(newimage));
         image =newimage;
         title(['iteration = ',num2str(iter)])
      end % if
   end % for iter
%return
