holypipette.vision.phase_cross_correlation module

Copied from scikit-image.registration 0.18.0. Masking removed.

holypipette.vision.phase_cross_correlation.phase_cross_correlation(reference_image, moving_image, upsample_factor=1, space='real', return_error=True, overlap_ratio=0.3)[source]

Efficient subpixel image translation registration by cross-correlation. This code gives the same precision as the FFT upsampled cross-correlation in a fraction of the computation time and with reduced memory requirements. It obtains an initial estimate of the cross-correlation peak by an FFT and then refines the shift estimation by upsampling the DFT only in a small neighborhood of that estimate by means of a matrix-multiply DFT. :Parameters: * reference_image (array) – Reference image.

  • moving_image (array) – Image to register. Must be same dimensionality as reference_image.

  • upsample_factor (int, optional) – Upsampling factor. Images will be registered to within 1 / upsample_factor of a pixel. For example upsample_factor == 20 means the images will be registered within 1/20th of a pixel. Default is 1 (no upsampling). Not used if any of reference_mask or moving_mask is not None.

  • space (string, one of “real” or “fourier”, optional) – Defines how the algorithm interprets input data. “real” means data will be FFT’d to compute the correlation, while “fourier” data will bypass FFT of input data. Case insensitive. Not used if any of reference_mask or moving_mask is not None.

  • return_error (bool, optional) – Returns error and phase difference if on, otherwise only shifts are returned. Has noeffect if any of reference_mask or moving_mask is not None. In this case only shifts is returned.

  • overlap_ratio (float, optional) – Minimum allowed overlap ratio between images. The correlation for translations corresponding with an overlap ratio lower than this threshold will be ignored. A lower overlap_ratio leads to smaller maximum translation, while a higher overlap_ratio leads to greater robustness against spurious matches due to small overlap between masked images. Used only if one of reference_mask or moving_mask is None.

Returns:

  • shifts (ndarray) – Shift vector (in pixels) required to register moving_image with reference_image. Axis ordering is consistent with numpy (e.g. Z, Y, X)

  • error (float) – Translation invariant normalized RMS error between reference_image and moving_image.

  • phasediff (float) – Global phase difference between the two images (should be zero if images are non-negative).

References