pro ift,movin,outp ; ; INDIVIDUAL FEATURE TRACKING (recurrent reference). ; The procedure tracks the motion of a bright or dark feature ; (selected in the first frame by a cursor) during a time-series ; of frames. Position and intensity are measured in each frame. ; ; Input : 3-d array MOVIN containing a time-series of frames ; Output: 2-d array OUTP: Frame.no.; X-position; Y-position; Intensity ; Calls : cor_imag, cor_anal, nint ; 24 January, 16 May 1995, Michal ; ;------------------ TUNABLE PARAMETERS -------------------------------------- fld= 9 ; 17 for 0.06"/pix, 9 for 0.12"/pix ;Size of the tracking field around the feature (pix). 1" recommended ww = 5 ; 7 for 0.06"/pix, 5 for 0.12"/pix ;Size of the field where to find the extremum (pix). 0.5" recommended csh= 4 ; 7 for 0.06"/pix, 4 for 0.12"/pix ;Value for xshift and yshift parameters in cor_imag (pix). ;---------------------------------------------------------------------------- dim=size(movin) if (dim(0) ne 3) then begin print,'Input must be a 3-D array (movie). STOPPED, type RETALL' stop endif outp=intarr(4,dim(3)) ; output array chmov=intarr(fld,fld,dim(3)) ; check movie ld=fld/2 ; defines the tracking field ud=fld/2 ; (ud=fld/2-1 for even value of fld) w=ww/2 window,0,xsize=dim(1),ysize=dim(2) tvscl,movin(*,*,0) ; first frame curs: print,'Select single feature with cursor' cursor,x,y,/device,/down ; get initial position read,'The selected feature is DARK (0), BRIGHT (1) or wrong (2) ?',mami if (mami gt 1 or mami lt 0) then goto,curs ; repeat selection chmov(0,0,0)=movin(x-ld:x+ud,y-ld:y+ud,0) ; initial subframe if (mami eq 0) then begin ; dark - looking for minimum val=min(movin(x-w:x+w,y-w:y+w,0),pos) ; in ww x ww environment xm=(pos mod ww)-w+x ; position in the whole frame ym=pos/ww-w+y endif else begin ; bright - looking for maximum val=max(movin(x-w:x+w,y-w:y+w,0),pos) ; in ww x ww environment xm=(pos mod ww)-w+x ; position in the whole frame ym=pos/ww-w+y endelse outp(0,0)=[0,xm,ym,val] ; 1st row of output print,'Initial position:',x,y,' Intensity:',movin(x,y,0) print,'Feature position:',xm,ym,' Intensity:',val for i=1,dim(3)-1 do begin a=movin(x-ld:x+ud,y-ld:y+ud,i-1) ; reference b=movin(x-ld:x+ud,y-ld:y+ud,i) ; current tracking field corrmat=cor_imag(a,b,xshift=csh,yshift=csh) ; correl_images... cor_anal,corrmat,xof,yof ; corrmat_analyze... print,'frame no.',i,' offset:',xof,yof if(abs(xof) gt (csh-1) or abs(yof) gt (csh-1)) then begin print,'*** TRACKING LOST ***' goto,fin endif x=x-xof & y=y-yof ; correction - new position chmov(0,0,i)=movin(x-ld:x+ud,y-ld:y+ud,i) if (mami eq 0) then begin ; dark - looking for minimum val=min(movin(x-w:x+w,y-w:y+w,i),pos) ; in ww x ww environment xm=(pos mod ww)-w+x ym=pos/ww-w+y endif else begin ; bright - looking for maximum val=max(movin(x-w:x+w,y-w:y+w,i),pos) ; in ww x ww environment xm=(pos mod ww)-w+x ym=pos/ww-w+y endelse outp(0,i)=[i,xm,ym,val] ; output endfor fin: outp=outp(*,0:i-1) ; truncation of empty elements chmov=chmov(*,*,0:i-1) ;(i-1 is the last processed frame) ; presentation movie,bytscl(rebin(chmov,fld*4,fld*4,i)),order=0 window,0 x1=min(outp(1,*))-5 & x2=max(outp(1,*))+5 y1=min(outp(2,*))-5 & y2=max(outp(2,*))+5 plot,outp(1,*),outp(2,*),/nodata,back=255,col=0,xra=[x1,x2],yra=[y1,y2],/xst,/yst for j=1,i-1 do arrow,outp(1,j-1),outp(2,j-1),outp(1,j),outp(2,j),col=0,/data end