%%a1_bonus
%comp 776 : assignment1
% 1.2.2 Prokudin-Gorskii image alignment with image pyramid
close all
pathDir='./data_hires';

fname='01861a.tif';

im=double(imread(sprintf('%s/%s',pathDir,fname)));

[H,W,N]=size(im);

h=floor(H/3);
b=im(1:h,:,:);
g=im(h+1:2*h,:,:);
r=im(2*h+1:3*h,:,:);
maxLag=40;
scaleMax=4;


 [xa,ya,xb,yb]=multiScaleAlign(r,g,b,maxLag,scaleMax);
 
 
  [g,b]=shiftImages(g,b,xa,ya,xb,yb);
  
  imColor=uint16(cat(3,r,g,b));
  figure,imshow(imColor);
%   imwrite(imColor,sprintf('%s-%s','col',fname));
  