function makesens(sens, pos, vel, psize, steps, directory, name)

% function creates sets of patches and saves them to disk
% sens = sensor image
% pos = initial patch location (top left corner)
% vel = shift per iteration
% psize = size of patch
% steps = length of patch sequence

displaypatch = 0;

figure(1)
clf
imshow(sens)                   % display patch
title('Second map')



%%%%%%%%%%%%
% Extract sequence of patches and draw in sens map


for n = 1 : steps

  % extract patch
  patch=sens(pos(1):pos(1)+psize, pos(2):pos(2)+psize);
  if displaypatch == 1
    figure(2)  
    hold on
    subplot(1,steps,n)
    imshow(patch)  
  end

  % show box in original image
  figure(1)
  hold on
  plot(line([pos(2),pos(2)+psize],[pos(1),pos(1)]));
  plot(line([pos(2),pos(2)+psize],[pos(1)+psize,pos(1)+psize]));
  plot(line([pos(2),pos(2)],[pos(1),pos(1)+psize]));
  plot(line([pos(2)+psize,pos(2)+psize],[pos(1),pos(1)+psize]));
  pos = pos + vel;
  

  % save patch
  fname = [directory '/' 'patch_' name '_' num2str(n) '_' num2str(psize) '.png'];
  imwrite(patch, fname);
end



