function [img] = generate_regular(im, nsite, template)

img = im*0+255;
wsizey = floor(size(template,1)/2);
wsizex = floor(size(template,2)/2);
for row = (floor(nsite/2)+1):floor(nsite):(size(im,1)-floor(nsite/2)-1),
  for col = (floor(nsite/2)+1):floor(nsite):(size(im,1)-floor(nsite/2)-1),
    img((row-wsizey):(row-wsizey+ size(template,1)-1), (col-wsizex):(col-wsizex+size(template,2)-1)) = template;
  end
end
return;

