Estimate the shift between images
#include "dip_findshift.h"
dip_Error dip_FindShift ( in1, in2, out, method, parameter )
binary, integer, float, complex
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.
If method is DIP_FSM_INTEGER_ONLY, integer shifts are calculated using cross correlation. This works for images of any dimensionality.
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.
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 method is more accurate than CPF.
This method supports images with a dimensionality between 1 and 3.
The ITER method is an iterative version of the MTS method. It is known that a single estimation with MTS has a bias due to truncation of the Taylor expansion series (Pham et al., 2005) The bias can be expressed as a polynomial of the subpixel displacements. As a result, if the MTS method is applied iteratively, and the shift is refined after each iteration, the bias eventually becomes negligible. By using just 3 iterations, and noticing that log(bias_increment) is a linear sequence, it is possible to correct for the bias up to O(1e-6).
Set parameter to 0 for normal behaviour. Other bahaviour is not supported, but: a parameter in the range (0,0.1] speficies the desired accuracy; parameter<0 causes round(-parameter) iterations to be run.
This method supports images with a dimensionality between 1 and 3.
The PROJ method computes the shift in each dimension separately, applying the ITER method on the various projections of the image onto a single axis. It is fast and fairly accurate for high SNR. Should not be used for low SNR.
This method supports images with any number of dimensions.
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 | Cross-correlation method |
DIP_FSM_FFTS | Same |
DIP_FSM_MTS | Taylor series method |
DIP_FSM_GRS | Same |
DIP_FSM_ITER | Iterative version of MTS |
DIP_FSM_PROJ | One-dimensional projectoin method |
DIP_FSM_NCC | Undocumented |
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