;******************************************************************** ;NAME : displace (procedure) ;FUNCTION : get the amount of displacement between 2 images ; K.I. '92/04/26 '92/05/01 ;==================================================================== pro displace,img1,img2,dx,dy,part1=part1,part2=part2,ver=ver ; INPUT ; img1,img2 : images ; /ver : display part1,part2 images in a window ; OUTPUT ; dx,dy : displacement distance between 2 images ; part1,part2 : spot area which is used for obtaining the displacement s=size(img1) nx=s(1) & ny=s(2) ; ------- find reference spot in img's ---------- dd=30 ; distance for taking 2-nd derivative wx=400 & wy=400 ; area for serching spot xs=nx/2-wx/2 & xe=xs+wx-1 ys=ny/2-wy/2 & ye=ys+wy-1 img=img1(xs:xe,ys:ye)/2 deriv = shift(img,dd,0)+shift(img,-dd,0)-2*img $ +shift(img,0,dd)+shift(img,0,-dd)-2*img max1=max(deriv(dd:wx-dd-1,dd:wy-dd-1),ii) yp1=ii/(wx-2*dd)+dd xp1=ii-(yp1-dd)*(wx-2*dd)+dd+xs yp1=yp1+ys wx=128 & wy=128 ; area for serching spot xs=xp1-wx/2 & xe=xs+wx-1 ys=yp1-wy/2 & ye=ys+wy-1 img=img2(xs:xe,ys:ye)/2 deriv = shift(img,dd,0)+shift(img,-dd,0)-2*img $ +shift(img,0,dd)+shift(img,0,-dd)-2*img max2=max(deriv(dd:wx-dd-1,dd:wy-dd-1),ii) yp2=ii/(wx-2*dd)+dd xp2=ii-(yp2-dd)*(wx-2*dd)+dd+xs yp2=yp2+ys ; ------- get gravity center of the spot --------- wxf=64 & wyf=64 ; area for calculating G-C around the spot xsf1=xp1-wxf/2 ysf1=yp1-wyf/2 part1=float(img1(xsf1:xsf1+wxf-1,ysf1:ysf1+wyf-1)) cx1=rebin(part1,wxf,1) gx1=total((max(cx1)-cx1)*lindgen(wxf))/total((max(cx1)-cx1)) cy1=transpose(rebin(part1,1,wyf)) gy1=total((max(cy1)-cy1)*lindgen(wyf))/total((max(cy1)-cy1)) xsf2=xp2-wxf/2 ysf2=yp2-wyf/2 part2=float(img2(xsf2:xsf2+wxf-1,ysf2:ysf2+wyf-1)) cx2=rebin(part2,wxf,1) gx2=total((max(cx2)-cx2)*lindgen(wxf))/total((max(cx2)-cx2)) cy2=transpose(rebin(part2,1,wyf)) gy2=total((max(cy2)-cy2)*lindgen(wyf))/total((max(cy2)-cy2)) if keyword_set(ver) then begin ; .display part1 & part2 window,5,xsize=wxf*2,ysize=wyf,xpos=0,ypos=900-wyf, $ title='displace: part1 & part2, C.G.' loadct,0 tvscl,part1,0,0 tvscl,part2,wxf,0 !order=0 xyouts,gx1,gy1,'!I!9X',size=2,alignment=0.5,color=255,/dev xyouts,gx2+wxf,gy2,'!I!9X',size=2,alignment=0.5,color=255,/dev endif dx=xp1-xp2+gx1-gx2 dy=yp1-yp2+gy1-gy2 print,'displace: dx,dy=',dx,dy end