bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / registration / _phase_cross_correlation / phase_cross_correlation
function
skimage.registration._phase_cross_correlation:phase_cross_correlation
source: /dev/scikit-image/src/skimage/registration/_phase_cross_correlation.py :202
Signature
def phase_cross_correlation ( reference_image , moving_image , * , upsample_factor = 1 , space = real , disambiguate = False , reference_mask = None , moving_mask = None , overlap_ratio = 0.3 , normalization = phase ) Summary
Efficient subpixel image translation registration by cross-correlation.
Extended Summary
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 [1].
Parameters
reference_image: arrayReference image.
moving_image: arrayImage to register. Must be same dimensionality as
reference_image.upsample_factor: int, optionalUpsampling factor. Images will be registered to within
1 / upsample_factorof a pixel. For exampleupsample_factor == 20means the images will be registered within 1/20th of a pixel. Default is 1 (no upsampling). Not used if any ofreference_maskormoving_maskis not None.space: {"real", "fourier"}, optionalDefines 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_maskormoving_maskis not None.disambiguate: boolThe shift returned by this function is only accurate modulo the image shape, due to the periodic nature of the Fourier transform. If this parameter is set to
True, the real space cross-correlation is computed for each possible shift, and the shift with the highest cross-correlation within the overlapping area is returned.reference_mask: ndarrayBoolean mask for
reference_image. The mask should evaluate toTrue(or 1) on valid pixels.reference_maskshould have the same shape asreference_image.moving_mask: ndarray or None, optionalBoolean mask for
moving_image. The mask should evaluate toTrue(or 1) on valid pixels.moving_maskshould have the same shape asmoving_image. IfNone,reference_maskwill be used.overlap_ratio: float, optionalMinimum allowed overlap ratio between images. The correlation for translations corresponding with an overlap ratio lower than this threshold will be ignored. A lower
overlap_ratioleads to smaller maximum translation, while a higheroverlap_ratioleads to greater robustness against spurious matches due to small overlap between masked images. Used only if one ofreference_maskormoving_maskis not None.normalization: {"phase", None}The type of normalization to apply to the cross-correlation. This parameter is unused when masks (
reference_maskandmoving_mask) are supplied.
Returns
shift: ndarrayShift vector (in pixels) required to register
moving_imagewithreference_image. Axis ordering is consistent with the axis order of the input array.error: floatTranslation invariant normalized RMS error between
reference_imageandmoving_image. For masked cross-correlation this error is not available and NaN is returned.phasediff: floatGlobal phase difference between the two images (should be zero if images are non-negative). For masked cross-correlation this phase difference is not available and NaN is returned.
Notes
The use of cross-correlation to estimate image translation has a long history dating back to at least [2]. The "phase correlation" method (selected by normalization="phase") was first proposed in [3]. Publications [1] and [2] use an unnormalized cross-correlation (normalization=None). Which form of normalization is better is application-dependent. For example, the phase correlation method works well in registering images under different illumination, but is not very robust to noise. In a high noise scenario, the unnormalized method may be preferable.
When masks are provided, a masked normalized cross-correlation algorithm is used [5], [6].
Aliases
-
skimage.registration.phase_cross_correlation