#!/usr/local/bin/perl
#this file derived from n1nlf-1:~> /usr/bin/perl rotate.pl 
$steps = sprintf("-steps 4 32 16 8 4");
# example: 4 4 3 2 1   does 4 then 3 then 2, then 1 (1 means none)
#          4 3 3 3 3   does 3 iterations at each of the 4 levels

$fileO = sprintf("parameters_pairwise.txt"); # cumulative
`rm $fileO`; # initialize to empty

$lastframe=133;  # e.g. if there are 250 frames numbered 0 to 249, enter 249

printf("\n");
for ($counter=001; $counter<=$lastframe; $counter++) {
  $filea = sprintf("images/legals%03d.jpg", $counter-1);
  $fileb = sprintf("images/legals%03d.jpg", $counter);

  $fileo = sprintf("porkparameters%03d_%03d.txt", $counter,$counter-1);
  # last line of above file is the final answer
  # above file is cumulative result

  printf("about to djpeg $filea and $fileb\n");
  `djpeg -g $filea > deleteme_deletemea.pgm`;
  `djpeg -g $fileb > deleteme_deletemeb.pgm`;
  printf("about to estimate\n");
  `est_pchirp2m_alpha_native_compiler deleteme_deletemea.pgm deleteme_deletemeb.pgm -outp $fileo -display $steps > pork_stdout.txt`;

  # cat files together
  `tail -1 $fileo > porkparameter`;
  `cat porkparameter >> $fileO`;

}

