function [dilated]=dilatation(im)
%USAGE: dilatation(image)
% Computes dilatation of binary image and structuring element [1 1 1]
%EXAMPLE:
% dilatation(imread('image.png'))
image=struct('data',im(:,:,1),'size',size(im));
if (length(image.size)>2) 
  warning('Converting image to grayscale.');
  image.data=rgb2gray(im);
  image.size(3)=1;
end
if (class(image.data)~='logical')
  image.data=im2bw(image.data,graythresh(image.data));
end

dilated=logical(zeros(image.size,'uint8'));

for i=1:image.size(1)
  for j=1:image.size(2)
    if image.data(i,j)==1 
      if (i~=1)
        dilated(i-1,j)=1;
      elseif (i~=image.size(1))
        dilated(i+1,j)=1;
      end
      dilated(i,j)=1;
    end
  end
end
