function image=generateTexture(row,col,type)
%
% function generateTexture
%
% example: i[row,col]=generateTexture(row,col,'odd');
%          mode:'odd','even','coin'
%

image=rand(row,col);
for i=1:row
  if (image(i,1)>=0.5)
    image(i,1)=1;
  else
    image(i,1)=0;
  end;
end;

for j=2:col
   if (image(1,j)>=0.5)
      image(1,j)=1;
   else 
      image(1,j)=0;
   end;
end;

if strcmp(type,'odd')
  for i=2:row
     for j=2:col
        image(i,j)=mod(image(i,1)+image(1,j)+image(1,1)+i*j,2);
     end;
  end;
elseif strcmp(type,'even')
   for i=2:row
      for j=2:col
        image(i,j)=mod(image(i,1)+image(1,j)+image(1,1),2);
      end;
   end;    
elseif strcmp(type,'coin')
   for i=2:row
     for j=2:col
       if (image(i,j)>=0.5)
         image(i,j)=1;
       else 
         image(i,j)=0;
       end;
     end;
   end;
end;
