prtools.register#
- register(arr, ref, oversample, return_error=False)[source]#
Compute the subpixel image translation to register the input array to a reference array.
The registration shift is computed in two steps: first a coarse estimate is computed from the FFT-based cross-correlation of the two input arrays. This estimate is then refined to subpixel accuracy by computing the upsampled DFT-based cross-correlation in a small neigborhood around the initial estimate.
- Parameters:
arr (array_like) – Array to register.
ref (array_like) – Target array.
oversample (float) – Oversampling factor for subpixel registration. Registration accuracy is 1/oversample.
return_error (bool, optional) – If True, the noramlized RMS registration error is returned. Default is False.
- Returns:
shift (tuple) – Translation in (row, col) that will register arr to ref.
err (float) – Registration error
References
Guizar-Sicairos, Thurman, and Fienup, “Efficient subpixel image registration algorithms”. Optics Letters 33, 156-158 (2008)
See also
Example
>>> ref = np.zeros((3,3)) >>> ref[1,1] = 1 >>> arr = np.zeros((3,3)) >>> arr[2,2] = 1 >>> shift = prtools.register(arr, ref, oversample=2) >>> shift (-1.0, -1.0)