% charles wyckoff in media lab doorway
% toshiba ikum42a ... auto shutter, area=1/4, agc off, 11mm lens
%                                   (thus no need to swarp)

more off

l1=0    % begin frame
l2=81    % end frame (there are 82 frames numbered 0 to 81)
err_history=[];
p=[];

for l = l1+1:l2   % pairwise of frames l1..l2-1 with l1+1..l2
  disp('since more keeps turning itself on, turning it off'); more off
  A = eval(sprintf('loadframe(%d)',l-1));
  figure(1);  % keep from running out of memory (limit fig use)
  B = eval(sprintf('loadframe(%d)',l));
  disp(sprintf('est_pairwisew: estimating translation at frame l=%d',l))
  disp('since more keeps turning itself on, turning it off'); more off
  p_trans=[est_trans_fft2(A,B) 0]; % now takes B to A
  p_now=est_pchirp2mw(A,B,5,3,p_trans,1);
  p=[p;p_now]; % concatenate each time
  disp('since more keeps turning itself on, turning it off'); more off
  mse=mean2nan(abs(A-pchirp2w(p_now,B)));
  err_history=[err_history;mse];
  s = sprintf('save parameters_pairwisemw5_3_%03d p err_history',l);
  disp(s)
  eval(s)
end%for

