function mat2gray(im);
%  
%   function mat2gray(im)
%  
%   
%  the m by n matrix is linearly scaled to fit the gray scale (levels 1:64)
%  using colormap('gray')
%
[m,n]=size(im);

minwas=min(min(im))
maxwas=max(max(im))

if (maxwas==minwas)
  im=ones(size(im));
else
  im=ceil(64*(im-(minwas))/(maxwas-minwas));
end

colormap('gray')

image(im)



