
214 Image Enhancement and Correction
Listing 5.12 : Image matching by phase correlation.
1 PRO e x5_5
2
3 ; read a JPEG image , cut out two 512 x512 pixel arrays
4 file name = Dialog_Pi ckfile ( Fi lter = ’*. jpg ’ ,/ READ )
5
6 IF filen ame EQ ’’ THEN RETU RN ELSE BEGIN
7 Read_JPeG , filename , image
8 g1 = image [0 ,10:521 ,10:521 ]
9 g2 = image [0 ,0: 511 ,0:51 1]
10
11 ; perf orm Fou rier trans forms
12 f1 = fft (g1 , / double )
13 f2 = fft (g2 , / double )
14
15 ; Dete rmine the offs et
16 g = fft ( f2 * conj ( f1 )/ abs ( f1 * conj ( f1 )) , $
17 / inverse ,/ dou ble )
18 pos = whe re (g EQ max ( g ))
19 PRINT , ’O ffset = ’+ st rtrim ( pos MOD 512) $
20