>> A=ovesamud(loadframe(1));
loadpnm: pnm header info: P6, 0..255, M=230, N=630
       : 3 lhs args specified so assuming color (24b)
loadframe.m: generating frame 1 from rgb; double check .3,.5,.2
>> B=ovesamud(loadframe(3));
loadpnm: pnm header info: P6, 0..255, M=230, N=630
       : 3 lhs args specified so assuming color (24b)
loadframe.m: generating frame 3 from rgb; double check .3,.5,.2
>> type cement

% cements 2 or more frames together, given the CUMULATIVE cross chirp between
%
% parameters are vectors, cumulatively expressed already
%
% Examples of use: first use P=pintegrate(p,3); % make cumulative, select lref
%                : C=cement(P,l1,l2); % calls loadframe.m to get ea. frame
%                : C=cement(P,l1,l2,skip_increment);
%                : C=cement(P,1,100,10); % uses every 10th frame
%                : C=cement(P,1,100,10,50); % highlights v50 w/ black border
%
% See also: cement_cumulative
%          (takes list of variables rather than calling loadframe)
%
% calls ``loadframe.m'' and ``pchirp2nocrop.m''

function empty=myname(P,l1,l2,skip_increment,borderedframe)

more off % make sure doesn't stop if screen full of text...

if nargin==3
  disp('cement: skip_increment defaulting to 1; we''ll use every frame in interval')
--more--          skip_increment=1;
end%if

if nargin==4
  dis('cement: running from frame %d, to frame %d, in increments of %d',...
      l1,l2,skip_increment)
end%if

if max(max(size(l1))) > 1
  error('cement: starting frame number (l1) must be a scalar')
end%if
if max(max(size(l2))) > 1
  error('cement: ending frame number (l2) must be a scalar')
end%if
if isstr(l1)
  error('cement: starting frame (l1) must be a NUMBER, not a string')
end%if
if isstr(l2)
  error('cement: ending frame (l2) must be a NUMBER, not a string')
end%if

[M_P, N_P]=size(P);
--more--        if N_P ~= 8
  error('cement: input parameters must be in matrix with rows of width 8')
end%if
if isstr(P)
  error('cement: input parameters must be numbers not a string')
end%if
if ~isreal(P)
  error('cement: input parameters must be real')
end%if

[Ml,Nl,Mh,Nh]=boundingboxextrema([P(l1+1:skip_increment:l2+1,:)]);
                                                % v03 to v15 uses P(4:16,:)
% note that P includes reference parameter which may or may not be the identity

for l=l1:skip_increment:l2
  dis('doing frame %d <=  ***** %d ***** <= %d (increment=%d) of %d frames total',l1,l,l2,skip_increment,l2-l1+1)
  eval(sprintf('v%02d=loadframe(%02d);',l,l)) % v00, v01, ... v99, v100, ...
  if (nargin==5)
    if l==borderedframe
      dis('cement: highlighting frame %02d with black border',l)
      eval(sprintf('v%02d=borderblack(v%02d,5,2);',l,l))
    end%if
--more--          end%if
  if l==l1 % find size from first frame, hope that all frames same size
    [M, N]=size(eval(sprintf('v%02d',l1)));
    % base on size of one of frames which should be equal so base on frame l1
    canvassize=[M*(Mh-Ml),  N*(Nh-Nl)];
    canvassize=2*ceil(canvassize/2);  % getting even with mpeg
    disp(sprintf('cement_cumulative: about to nalloc %d by %d canvas (approx %7.3g Meg)',canvassize, 8*prod(canvassize)/(1024.^2)))
    empty=NaN*ones(ceil(canvassize));
  else%if % each time, check that other frames are same size as first
    [Mnow, Nnow]=size(eval(sprintf('v%02d',l)));
    if Mnow~=M
      error(sprintf('cement: frame %d different height than first frame',l))
    end%if
    if Nnow~=N
      error(sprintf('cement: frame %d different width than first frame',l))
    end%if
  end%if l==0
  % now insert frame l:
  eval(sprintf('[v%02dd,Ml%02d,Nl%02d]=pchirp2nocrop(P(%02d+1,:),v%02d,1,-1,NaN);',...
               l,l,l,l,l))  % note P(4,:) pertains to v03, etc.
  eval(sprintf('clear v%02d',l))
  eval(sprintf('[M%02d,N%02d]=size(v%02dd);',l,l,l)) % size after dechirp
--more--          eval(sprintf('Mh%02d=Ml%02d+(M%02d-1)/M%02d; Nh%02d=Nl%02d+(N%02d-1)/N%02d;',l,l,l,l,l,l,l,l))
  eval(sprintf('Mpixell%02d=round(M*Ml%02d+1   - M*Ml);',l,l))
  eval(sprintf('Mpixelh%02d=round(M*Ml%02d+M%02d - M*Ml);',l,l,l))
  eval(sprintf('Npixell%02d=round(N*Nl%02d+1   - N*Nl);',l,l))
  eval(sprintf('Npixelh%02d=round(N*Nl%02d+N%02d - N*Nl);',l,l,l))




  % UNCOMMENT ONE OF THESE (max, mean, new, newbroken):

  %eval(sprintf('empty(Mpixell%02d:Mpixelh%02d, Npixell%02d:Npixelh%02d)=maxnan(empty(Mpixell%02d:Mpixelh%02d, Npixell%02d:Npixelh%02d),v%02dd);',l,l,l,l,l,l,l,l,l))

  %eval(sprintf('empty(Mpixell%02d:Mpixelh%02d, Npixell%02d:Npixelh%02d)=meannan(empty(Mpixell%02d:Mpixelh%02d, Npixell%02d:Npixelh%02d),v%02dd);',l,l,l,l,l,l,l,l,l))

  % meancertain seems to give parts of the image looking negated for image sequence that doesn't have agc or such changes...
  eval(sprintf('empty(Mpixell%02d:Mpixelh%02d, Npixell%02d:Npixelh%02d)=meancertainnan(empty(Mpixell%02d:Mpixelh%02d, Npixell%02d:Npixelh%02d),v%02dd);',l,l,l,l,l,l,l,l,l))

  %eval(sprintf('empty(Mpixell%02d:Mpixelh%02d, Npixell%02d:Npixelh%02d)=newnan(empty(Mpixell%02d:Mpixelh%02d, Npixell%02d:Npixelh%02d),v%02dd);',l,l,l,l,l,l,l,l,l))
  
  %eval(sprintf('empty(Mpixell%02d:Mpixelh%02d, Npixell%02d:Npixelh%02d)=feathernewnan(empty(Mpixell%02d:Mpixelh%02d, Npixell%02d:Npixelh%02d),v%02dd,21);',l,l,l,l,l,l,l,l,l)) % last arg of feathernewnan is feather radius
  
--more--          %eval(sprintf('empty(Mpixell%02d:Mpixelh%02d, Npixell%02d:Npixelh%02d)=v%02dd;',l,l,l,l,l))





  eval(sprintf('clear v%02dd',l))
end%for


%% what used to be there before eval(sprintf(' 
%% % insert v02
%% if LENGTH_P >=02+1
%%   [v02d,Ml02,Nl02]=pchirp2nocrop(P(02+1,:),v02);
%%   clear v02
%%   [M02,N02]=size(v02d);
%%   Mh02=Ml02+(M02-1)/M02; Nh02=Nl02+(N02-1)/N02;
%%   Mpixell02=round(M*Ml02+1   - M*Ml);
%%   Mpixelh02=round(M*Ml02+M02 - M*Ml);
%%   Npixell02=round(N*Nl02+1   - N*Nl);
%%   Npixelh02=round(N*Nl02+N02 - N*Nl);
%%   empty(Mpixell02:Mpixelh02, Npixell02:Npixelh02)=maxnan(...
--more--        %%   empty(Mpixell02:Mpixelh02, Npixell02:Npixelh02),v02d);
%%   clear v02d
%% end%if

%% % insert v03
%% ...


>> type cement

% cements 2 or more frames together, given the CUMULATIVE cross chirp between
%
% parameters are vectors, cumulatively expressed already
%
% Examples of use: first use P=pintegrate(p,3); % make cumulative, select lref
%                : C=cement(P,l1,l2); % calls loadframe.m to get ea. frame
%                : C=cement(P,l1,l2,skip_increment);
%                : C=cement(P,1,100,10); % uses every 10th frame
%                : C=cement(P,1,100,10,50); % highlights v50 w/ black border
%
% See also: cement_cumulative
%          (takes list of variables rather than calling loadframe)
%
% calls ``loadframe.m'' and ``pchirp2nocrop.m''

function empty=myname(P,l1,l2,skip_increment,borderedframe)

more off % make sure doesn't stop if screen full of text...

if nargin==3
  disp('cement: skip_increment defaulting to 1; we''ll use every frame in interval')
--more--          skip_increment=1;
--more--        end%if
--more--        
--more--        if nargin==4
  dis('cement: running from frame %d, to frame %d, in increments of %d',...
      l1,l2,skip_increment)
end%if

if max(max(size(l1))) > 1
  error('cement: starting frame number (l1) must be a scalar')
end%if
if max(max(size(l2))) > 1
  error('cement: ending frame number (l2) must be a scalar')
end%if
if isstr(l1)
  error('cement: starting frame (l1) must be a NUMBER, not a string')
end%if
if isstr(l2)
  error('cement: ending frame (l2) must be a NUMBER, not a string')
end%if

[M_P, N_P]=size(P);
if N_P ~= 8
  error('cement: input parameters must be in matrix with rows of width 8')
end%if
--more--        
>> which cement
/mann/a/a/bigu/cement/motion_est/cement.m
>> !vi /mann/a/a/bigu/cement/motion_est/cement.m
>> type est_pairwise

% sci. am. at east campus outdoor table

l1=0    % begin frame
l2=47   % end frame (there are 48 frames numbered 0 to 47)

err_history=[]; p=[];

more off

for l = l1+1:l2   % pairwise of frames l1..l2-1 with l1+1..l2
  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('--- estimating translation frame 0 to %d',l))
  p_trans=est_trans_fft2(A,B); % now takes B to A
  p_now=est_pchirp2m(A,B,3,3,p_trans,1);
  p=[p;p_now]; % concatenate each time
  mse=mean2nan(abs(A-pchirp2(p_now,B)));
  err_history=[err_history;mse];
  s = sprintf('save parameters_pairwisem_3_3_%03d p err_history',l);
  disp(s)
--more--          eval(s)
end%for


>>   disp(sprintf('--- estimating translation frame 0 to %d',l))
??? Undefined function or variable l.

>>   p_trans=est_trans_fft2(A,B); % now takes B to A
est_trans_fft2: exponent defaulting to 1, so we have phase only
motion_cross_fft2.m: using add-hoc window (found far better than rect)
motion_cross_fft2: about to mult FFTs and div by magnitudes (phase only)
est_motion_fft2: 1 output arg. given so generating p vector
>>   p_now=est_pchirp2m(A,B,3,3,p_trans,1);
est_pchirp2m: now doing level 3
tvs: last colormap entry not red (for NaN): setting map to gray+1extra red
greynan: setting colormap to 64 grey levels + red to make 65 levels total
est_pchirp2r: formatted state-variables at each itteration displayed below:
set 1: +1.000000  +0.000000  -0.095652     +0.000000  +1.000000  +0.019048
       +0.000000                           +0.000000
pchirp2: output size defaulting to input size
pchirp2: output scaling defaulting to on
est_pseudo: adding identity and converting from pel to norm'd [0,1) rep.
itt 2:  +1.001996  +0.000894  -0.095722     +0.006320  +1.004300  +0.012836
        +0.005908                           -0.003571
pchirp2: output size defaulting to input size
pchirp2: output scaling defaulting to on
est_pseudo: adding identity and converting from pel to norm'd [0,1) rep.
itt 3:  +1.000879  +0.001195  -0.095301     +0.006749  +1.004006  +0.012981
        +0.006298                           -0.003740
est_pchirp2m: now doing level 2
tvs: last colormap entry not red (for NaN): setting map to gray+1extra red
greynan: setting colormap to 64 grey levels + red to make 65 levels total
est_pchirp2r: formatted state-variables at each itteration displayed below:
set 1: +1.000879  +0.001195  -0.095301     +0.006749  +1.004006  +0.012981
       +0.006298                           -0.003740
pchirp2: output size defaulting to input size
pchirp2: output scaling defaulting to on
est_pseudo: adding identity and converting from pel to norm'd [0,1) rep.
itt 2:  +1.000751  +0.001456  -0.095407     +0.006780  +1.004329  +0.012984
        +0.006151                           -0.003277
pchirp2: output size defaulting to input size
pchirp2: output scaling defaulting to on
est_pseudo: adding identity and converting from pel to norm'd [0,1) rep.
itt 3:  +1.000806  +0.001442  -0.095446     +0.006790  +1.004426  +0.012970
        +0.006150                           -0.003211
>>   p=[p;p_now]; % concatenate each time
>>   mse=mean2nan(abs(A-pchirp2(p_now,B)));
pchirp2: interp_order defaulting to 1
pchirp2: antialias method defaulting to -1 (none)
pchirp2: myNaN defaulting to NaN
pchirp2: output size defaulting to input size
pchirp2: output scaling defaulting to on
>>   err_history=[err_history;mse];
>>   s = sprintf('save parameters_pairwisem_3_3_%03d p err_history',l);
??? Undefined function or variable l.

>>   disp(s)
??? Undefined function or variable s.

>>   eval(s)
??? Undefined function or variable s.

>> pwd
ans =
/mann/a/a/htdocs/lieorbits/levis/orbit1
>> which est_pchirp2m
/mann/a/a/bigu/cement/motion_est/est_pchirp2m.m
>> !vi /mann/a/a/bigu/cement/motion_est/est_pchirp2m.m
>> !vi /mann/a/a/bigu/cement/motion_est/est_pchirp2r.m
>> !view /var/mail/mann
>> !vi /mann/a/a/bigu/cement/motion_est/est_pchirp2r.m
>> !vi /mann/a/a/bigu/conf/chirplet.bib
>> !vi /mann/a/a/bigu/cement/motion_est/est_pchirp2r.m
>> est_pchirp2m(A,B,1,1)
est_pchirp2m: estimating init parameters from the two smoothed images
tvs: last colormap entry not red (for NaN): setting map to gray+1extra red
greynan: setting colormap to 64 grey levels + red to make 65 levels total
est_pchirp2r: formatted state-variables at each itteration displayed below:
est_pchirp2: estimating initial parameters from the two images:
est_pseudo: adding identity and converting from pel to norm'd [0,1) rep.
est 1:  +0.999739  -0.002295  +0.000630     +0.000333  +1.001969  -0.000018
        +0.003409                           -0.001215
est_pchirp2m: numlevels to skip defaulting to 1 (skipping top level)
est_pchirp2m: 0 output args given so I'll tell you a little more,
              like where E1 corners correspond to E2
            +0.3/460      -0.8/460    +459.2/460    +458.1/460
            -0.0/630    +632.0/630      +0.2/630    +630.1/630
>> !vi /mann/a/a/bigu/cement/motion_est/est_pchirp2r.m
>> est_pchirp2m(A,B,1,1)
est_pchirp2m: estimating init parameters from the two smoothed images
tvs: last colormap entry not red (for NaN): setting map to gray+1extra red
greynan: setting colormap to 64 grey levels + red to make 65 levels total
est_pchirp2r: formatted state-variables at each iteration displayed below:
est_pchirp2: estimating initial parameters from the two images:
est_pseudo: adding identity and converting from pel to norm'd [0,1) rep.
est 1:  +0.999739  -0.002295  +0.000630     +0.000333  +1.001969  -0.000018
        +0.003409                           -0.001215
est_pchirp2m: numlevels to skip defaulting to 1 (skipping top level)
est_pchirp2m: 0 output args given so I'll tell you a little more,
              like where E1 corners correspond to E2
            +0.3/460      -0.8/460    +459.2/460    +458.1/460
            -0.0/630    +632.0/630      +0.2/630    +630.1/630
>> !vi /mann/a/a/bigu/cement/motion_est/est_pchirp2r.m
>> est_pchirp2m(A,B,1,1)
est_pchirp2m: estimating init parameters from the two smoothed images
tvs: last colormap entry not red (for NaN): setting map to gray+1extra red
greynan: setting colormap to 64 grey levels + red to make 65 levels total
est_pchirp2r: formatted state-variables at each iteration displayed below:
est_pchirp2: estimating initial parameters from the two images:
est_pseudo: adding identity and converting from pel to norm'd [0,1) rep.
est 1:  +0.999739  -0.002295  +0.000630     +0.000333  +1.001969  -0.000018
        +0.003409                           -0.001215
est_pchirp2m: numlevels to skip defaulting to 1 (skipping top level)
est_pchirp2m: 0 output args given so I'll tell you a little more,
              like where E1 corners correspond to E2
            +0.3/460      -0.8/460    +459.2/460    +458.1/460
            -0.0/630    +632.0/630      +0.2/630    +630.1/630
>> !vi /mann/a/a/bigu/cement/motion_est/est_pchirp2r.m
>> xlabel('IEEE TIP Sept 97 Vol6 No9, US Pat.')
>> xlabel('5706416 mann@eecg.toronto.edu')
>> subplot(221);xlabel('IEEE TIP Sept 97 Vol6 No9, US Pat.')
>> subplot(222);xlabel('5706416 mann@eecg.toronto.edu')
>> subplot(221);xlabel('IEEE TIP Sept 97 Vol6 No9, US Pat.    ')
>> subplot(221);xlabel('IEEE TIP Sept 97 Vol6 No9, US Pat.     ')
>> !vi /mann/a/a/bigu/cement/motion_est/est_pchirp2r.m
>> 
>> 
>> diary off
