function [xa,ya,xb,yb]=alignImages(ref,a,b,maxLag)
ref=double(edge(ref,'canny'));
a=double(edge(a,'canny'));
b=double(edge(b,'canny'));

[h,w]=size(ref);
c = xcorr2(a,ref);

c=c( h-maxLag:h+maxLag, w-maxLag:w+maxLag);

[ypeak, xpeak] = find(c==max(c(:)));% y is row

ya = ypeak-maxLag;
xa = xpeak-maxLag;


c = xcorr2(b,ref);

c=c( h-maxLag:h+maxLag, w-maxLag:w+maxLag);


[ypeak, xpeak] = find(c==max(c(:)));

yb = ypeak-maxLag;
xb = xpeak-maxLag;


end