ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/JSOC/proj/flatfield/off_flat_IDL/trk.pro
Revision: 1.1
Committed: Fri Feb 18 00:26:40 2011 UTC (12 years, 7 months ago) by richard
Branch: MAIN
CVS Tags: Ver_6-0, Ver_6-1, Ver_6-2, Ver_6-3, Ver_6-4, Ver_9-1, Ver_5-14, Ver_5-13, Ver_LATEST, Ver_9-3, Ver_9-41, Ver_9-2, Ver_8-8, Ver_8-2, Ver_8-3, Ver_8-0, Ver_8-1, Ver_8-6, Ver_8-7, Ver_8-4, Ver_8-5, Ver_7-1, Ver_7-0, Ver_9-5, Ver_9-4, Ver_8-10, Ver_8-11, Ver_8-12, Ver_9-0, HEAD
Log Message:
IDL package to calculate offpoint flatfield, dark frames, and bad pixel lists from spacecraft offpoints
2011.02.17

File Contents

# Content
1
2 ;+
3 ; NAME: TRK
4 ; PURPOSE:
5 ; This function, given an 2 images, will return the shifts in
6 ; x and y direction that will align the second
7 ; image b with respect to a.
8 ; CATEGORY:
9 ; image processing
10 ; CALLING SEQUENCE:
11 ; shift = trk(img,ref,mask=mask)
12 ; INPUTS:
13 ;
14 ; img - The image that you want to track with
15 ; respect to a.
16 ; type: array,any type,arr(nx,ny)
17 ; ref - The reference image.
18 ; type: array,any type,arr(nx,ny)
19 ;
20 ; OUTPUTS:
21 ;
22 ; shifts = vector containing shifts
23 ; TYPE: float(2)
24 ;
25 ; KEYWORDS
26 ; mask = fourier filter is applied to image and reference
27 ; currently available,
28 ; mask = 1 -> highpass
29 ; mask = 2 -> butterwoth highpass
30 ;
31 ; SIDE EFFECTS: None.
32 ; RESTRICTIONS: None.
33 ; PROCEDURE:
34 ; MODIFICATION HISTORY:
35 ; Dec. 91 TR
36 ; Feb. 07 RW (avoids sticking to flat field)
37 ;-
38 ;
39
40 function trk,img,ref,mask=mask,sub=sub,sf=sf, ccf=ccf, flatfield=flatfield
41
42 ;print,'track is running'
43
44 ;Compute sizes of a and b and nx and ny
45 sza=size(img) & szb=size(ref)
46 nx=sza(1) & ny=sza(2)
47 shifts = fltarr(2)
48 ma = 1
49
50 ;Array size : ERROR CHECK.
51 if (sza(0) ne szb(0))or(sza(1) ne szb(1))or(sza(2) ne szb(2)) then begin
52 print,'Array sizes not equal'
53 return,0
54 endif
55
56 if keyword_set(sub) then begin
57 subz = sub
58 if keyword_set(mask) then begin
59 case mask of
60 1: ma = hipass(subz,subz)
61 2: ma = bwth(subz,subz)
62 endcase
63 endif
64 lox = nx/2-subz/2
65 hix = lox+subz-1
66 loy = ny/2-subz/2
67 hiy = loy+subz-1
68
69 endif else begin
70 lox=0
71 hix=nx-1
72 loy=0
73 hiy=ny-1
74 if keyword_set(mask) then begin
75 case mask of
76 1: ma = hipass(nx,ny)
77 2: ma = bwth(nx,ny)
78 endcase
79 endif
80 endelse
81
82 sref=ref(lox:hix,loy:hiy)
83 simg=img(lox:hix,loy:hiy)
84 if keyword_set(sf) then begin
85 sref=sref-sfit(sref,1)
86 simg=simg-sfit(simg,1)
87 endif
88
89 ;Compute fft's
90 fref=fft(sref,-1) & fimg=fft(simg,-1)
91
92 ;Compute the correlation between the two images (ccf)
93 ccf=fft(fimg*conj(fref)*ma,1)
94
95
96 ;Compute nx/2 and ny/2
97 sz = size(sref)
98 sx=sz(1)/2 & sy=sz(2)/2
99
100 ;Convert ccf to float and shift.
101 ccf=float(ccf) & ccf=shift(ccf,sx,sy)
102
103 ;interpolate ccf at center point to avoid sticking to the flat field
104
105
106 if keyword_set(flatfield) then begin
107 c4x=(spline([findgen(7), 8+findgen(7)], [ccf[sx-7:sx-1, sy], ccf[sx+1:sx+7, sy]], findgen(15)))[7]
108 c4y=(spline([findgen(7), 8+findgen(7)], [reform(ccf[sx, sy-7:sy-1]), reform(ccf[sx, sy+1:sy+7])], findgen(15)))[7]
109 ccf[sx,sy]=0.5*(c4x+c4y)
110 endif
111
112 ;Find position of max of ccf.
113 ps=max_pos(ccf)
114
115 ;Determine shift and shift function.
116 sx=ps(0)-sx
117 sy=ps(1)-sy
118 shifts(0)=-sx
119 shifts(1)=-sy
120
121 ;print,'Shifts in x and y',-sx,-sy
122
123
124
125 return, shifts
126
127 end