understanding fft- based algorithm to calculate image displacements with idl programming language by...

15
Understanding FFT- based algorithm to calculate image displacements with IDL programming language By Cynthia Rodriguez By Cynthia Rodriguez University of Texas at San University of Texas at San Antonio Antonio

Upload: avery-devonshire

Post on 14-Dec-2015

228 views

Category:

Documents


7 download

TRANSCRIPT

Page 1: Understanding FFT- based algorithm to calculate image displacements with IDL programming language By Cynthia Rodriguez University of Texas at San Antonio

Understanding FFT- based algorithm to calculate

image displacements with IDL programming language

By Cynthia RodriguezBy Cynthia Rodriguez

University of Texas at San AntonioUniversity of Texas at San Antonio

Page 2: Understanding FFT- based algorithm to calculate image displacements with IDL programming language By Cynthia Rodriguez University of Texas at San Antonio

Automatic image registration

Automatic image registration - is the process that aligns one image to a second image of the same scene One image is known as the reference data, and the other image, is known as the input data (or sensed data), which is matched relative to the reference data. This is done so that the properties of an object being imaged can be addressable by the same coordinate pair from either one of the images.

Page 3: Understanding FFT- based algorithm to calculate image displacements with IDL programming language By Cynthia Rodriguez University of Texas at San Antonio

FFT- based algorithm

Several different algorithms to solve Several different algorithms to solve automatic image registrationautomatic image registration

FFT stands for Fast Fourier TransformFFT stands for Fast Fourier Transform

Formula proven as a successful factor in Formula proven as a successful factor in solving solving automatic image registrationautomatic image registration

Page 4: Understanding FFT- based algorithm to calculate image displacements with IDL programming language By Cynthia Rodriguez University of Texas at San Antonio

The Basic Idea

FFT based automatic registration relies on the Fourier shift theorem, which guarantees that the phase of a specifically defined “ratio” is equal to the phase

difference between the images.

Ex: Ratio = (x0,y0), [I2(x,y) = I1(x-x0, y-y0)]To find displacement between two images

Compute the Ratio

Ratio = F1 conj(F2 ) / | F1F2 |And Apply

Inverse Fourier transform

Images I1 and I2

Differ by a shift

(x0,y0)

Page 5: Understanding FFT- based algorithm to calculate image displacements with IDL programming language By Cynthia Rodriguez University of Texas at San Antonio

The Basic Idea

By applying the Inverse Fourier transform to the Ratio, we get an array of numbers returned that

is zero everywhere except for a small area around a single point. By using the Max function

we can find the maximum valueThe location of the Max value is exactly the

displacement (x0,y0) that is needed to optimally register the images.

Images I1 and I2

Differ by a shift

(x0,y0)

X 0 1 2Y

0

1

2

0 0 0

0 0 0

0.6 1 0.3

Max value location (1, 2)

Page 6: Understanding FFT- based algorithm to calculate image displacements with IDL programming language By Cynthia Rodriguez University of Texas at San Antonio

Pseudocode for shift_idl.pro

Declare and Initiate variables

‘n’ representing columns

‘m’ representing lines or rows

Create a byte array

Open and read image 1 file into im1 variable

Call function FFT for im1

Repeat above steps for im2

Calculate ratio F1 conj(F2 ) / | F1F2 |

Call function inverse FFT on ratio

Page 7: Understanding FFT- based algorithm to calculate image displacements with IDL programming language By Cynthia Rodriguez University of Texas at San Antonio

Cont. Pseudocode for shift_idl.proThe Result from FFT

Function Inverse FFT returns an array, with approximate zeros everywhere except at the displacement that is used to register the images. Call Max function to get the position of max value in array (the location of max is where the displacement (x0, y0) is)

To find x and y coordinate of shift, (x0, y0), use MOD and Divide operatorLast make a conditional statement to check for shifts to the west and north that are negative numbers. While shifts to the east and south are positive.

Page 8: Understanding FFT- based algorithm to calculate image displacements with IDL programming language By Cynthia Rodriguez University of Texas at San Antonio

Rotating and Scaling Too!

Convert abs(F(ε,n)) from rectangular coordinates (x, y) to log-polar coordinates (log (p), θ) to represent both scaling and rotation as shifts. However computing (log (p), θ) for the rectangular grid coordinates leads to points that are not located exactly at points on the original grid. So interpolation is used to find the correct value on the new grid. Bilinear interpolation is used in this program.

X 0 1 2Y

0

1

2

0 i 0

i j i

0.6 i 0.3

Bilinear Interpolation

Get intensities surrounding

around M(x,y) j

then interpolate

To find new value for M(x,y)

Page 9: Understanding FFT- based algorithm to calculate image displacements with IDL programming language By Cynthia Rodriguez University of Texas at San Antonio

Pseudocode for srs_idl.proDeclare and initiate variables

Call function Loadimage ( opens and reads data into Im1 and Im2)

Call function Normalize ( gets grid values in array and makes the array a floating array and divides values by 255.0 to make values between 0 and 1)

Call procedure ShiftArr (makes values in array negative values, if divisible by 2 with a remainder equal to 1)

Call FFT (which is a built-in IDL function) does Fast Fourier transfrom on each image

Call abs (also built-in function) gets absolute values on each image

Call function Highpass (removes low frequency noise) to the absolute values.

Page 10: Understanding FFT- based algorithm to calculate image displacements with IDL programming language By Cynthia Rodriguez University of Texas at San Antonio

Cont. Pseudocode for srs_idl.proCall function LogPolar on im1 and im2 (Transforms rectangular coordinates to log-polar coordinates.)To carry this function out accurately, the polar plane must have the same number of rows as the rectangular plane.To achieve this, create a nested for loop to go through each index in the array and individually get each coordinate and transfer it to log polar coordinate.After getting coordinates, Apply Bilinear interpolation which gets surrounding values of (x0, y0) then interpolate as

M(x,y)=Mjk(1-t)(1-u) + Mj+1,k t(1-u) + Mj,k+1(1-t)u + Mj+1,k+1tu,

t is a fractional part of x and u is a fractional part of y

Page 11: Understanding FFT- based algorithm to calculate image displacements with IDL programming language By Cynthia Rodriguez University of Texas at San Antonio

Cont. Pseudocode for srs_idl.proCall FFT function on polar coordinates for im1 and im2Call function Ritio to both fft_polar1 and fft_polar2

F1 conj(F2 ) / | F1F2 |

Call FFT inverse function for RatioApply absolute function to inverse RatioFind position of Max number in array of absolute valuesWith Max position find the values for scale and angle scale=b^(position MOD rows)

angle=180.0 * (position/rows) /cols

Page 12: Understanding FFT- based algorithm to calculate image displacements with IDL programming language By Cynthia Rodriguez University of Texas at San Antonio

Cont. Pseudocode for srs_idl.proOnce the angle is found make a conditional statement to check to see if the angle is greater than or less than 90.0. A positive angle means that the image is rotated to the east relative to the base image (clockwise), A negative angle means that the image is rotated to the west (counterclockwise) Assume angle computed is between [0,180]. If angle is less than 90, the actual angle is the negative of the computed one. If angle is greater than or equal to 90, then the actual rotation angle is 180 – computed angle. With angle and scale, create new image3 with function ROT (constructs new image by doing reverse rotation and reverse scaling)

Page 13: Understanding FFT- based algorithm to calculate image displacements with IDL programming language By Cynthia Rodriguez University of Texas at San Antonio

Cont. Pseudocode for srs_idl.proNext Steps like shift_idl.pro

Call FFT function for image1 and image3

Compute Ratio

Call inverse FFT on Ratio

Find Max number of array and get position

Get coordiantes of position

Check to see if coordinates are out of bounds and adjust accordingly for north and west shifts which are computed as negative.

Page 14: Understanding FFT- based algorithm to calculate image displacements with IDL programming language By Cynthia Rodriguez University of Texas at San Antonio

ResultsENVI> .COMPILE "D:\idlproject\shift_idl.pro"Compiled module: SHIFT_IDL.ENVI> shift_idlI = 7050this is max = ( 92546.2, -0.000154680)Position = 50 20ENVI> .COMPILE "D:\idlproject\srs_idl.pro"Compiled module: RITIO. Compiled module: LOGPOLAR. Compiled module: HIGHPASS. Compiled module: COMBINEFFT. Compiled module: LOADIMAGE. Compiled module: NORMALIZE. Compiled module: SHIFTARR. Compiled module: SRS_IDL.ENVI> srs_idlLoading images...Doing FFT on two images...Getting absolute value...Transformming log_polar coordinates...Doing FFT on polar images...max absolute value position= 143217total number of elements 160000max absolute value = 10522.9computed scale = 1.28999computed angle = 18.9000this is IRI = 7603this is max = ( 14344.0, 5.01551e-005)Position = 3 19

Page 15: Understanding FFT- based algorithm to calculate image displacements with IDL programming language By Cynthia Rodriguez University of Texas at San Antonio

Summary

The shift only program contains two forward FFTs and one inverse FFT

The scale, rotation, and shift program contains six forward FFTs and two inverse FFTs and requires more time and memory.

These two programs provide Automatic Registration

THE END