DIPlib Documentation - ©1995-2013 Quantitative Imaging Group, Delft University of Technology.

# FindShift

Estimate the shift between images

## SYNOPSIS

`#include "dip_findshift.h"`

dip_Error dip_FindShift ( in1, in2, out, method, parameter )

## DATA TYPES

binary, integer, float, complex

## FUNCTION

This function estimates the (sub-pixel) global shift between `in1` and `in2`. The numbers found represent the shift of `in1` with respect to `in2`, or the position of the first pixel of `in2` in the coordinate system of `in1`. There are two methods that can be used: CPF and MTS. Both methods require that the shift be small. Therefore, first the integer pixel is calculated, and both images are cropped to the common part.

If `method` is 0, `DIP_FSM_MTS` is used. `method` can also be `DIP_FSM_INTEGER_ONLY`. Integer shifts can be calculated for images of any dimensionality.

## CPF

The CPF method (marked as FFTS in the literature below) uses the phase of the cross-correlation (as calculated by `CrossCorrelationFT`) to estimate the shift. `parameter` sets the amount of frequencies used in this estimation. The maximum value that makes sense is sqrt(1/2). Any larger value will give the same result. Choose smaller values to ignore the higher frequencies, which have a smaller SNR and are more affected by aliasing. If `parameter` is set to 0, the optimal found for images sub-sampled by a factor four will be used (parameter = 0.2).

This method only supports 2-D images (until further notice).

## MTS

The MTS method (marked as GRS in the literature below) uses a first order Taylor approximation of the equation `in1(t) = in2(t-s)` at scale `parameter`. Setting `parameter` to zero, a scale of 1 will be used. This means that the images will be smoothed with a Gaussian kernel of 1. This is the more accurate one of the two methods, and therefore is the default.

This method supports images with a dimensionality between 1 and 3.

## ITER

The ITER method is an iterative version of the MTS method. It is known that a single gradient based shift estimation have bias due to truncation of the Taylor expansion series (see Pham et.al.) The bias can be expressed as a polynomial of the subpixel displacements. As a result, if Taylor method is applied iteratively and the shift is refined after each iteration, the bias eventually become negligible. By using just 3 iterations, it is possible to correct bias that results in high precision O(1e-6).

## PROJ

The PROJ method compute shift in each dimension from images' projections. It is fast and fairly accurate for high SNR. Should not be used for low SNR

## ARGUMENTS

Data type | Name | Description
`dip_Image` | `in1` | Input image
`dip_Image` | `in2` | Input image
`dip_FloatArray` | `out` | Estimated shift
`dipf_FindShiftMethod` | `method` | Estimation method
`dip_float` | `parameter` | Parameter

The `dipf_FindShiftMethod` enumeration consists of the following flags:

Name | Description
`DIP_FSM_DEFAULT` | Default method (MTS)
`DIP_FSM_INTEGER_ONLY` | Find only integer shift
`DIP_FSM_CPF` | Use cross-correlation method
`DIP_FSM_FFTS` | Same
`DIP_FSM_MTS` | Use Taylor series method
`DIP_FSM_GRS` | Same

## LITERATURE

C.L. Luengo Hendriks, Improved Resolution in Infrared Imaging Using Randomly Shifted Images, M.Sc. Thesis, Delft University of Technology, 1998 T.Q. Pham, M. Bezuijen, L.J. van Vliet, K. Schutte, C.L. Luengo Hendriks, Performance of Optimal Registration Estimators, In Proc. of SPIE 5817 - Visual Information Processing XIV, Defense and Security Symposium, Orlando, 2005

## SEE ALSO

`CrossCorrelationFT`