ncempy.eval.multicorr module

ncempy.eval.multicorr.multicorr(g1, g2, method='cross', upsample_factor=1, verbose=False)[source]

Align a reference to an image by cross correlation. The template and the image must have the same size.

The function takes in FFTs so that any FFT algorithm can be used to transform the image and template (fft2, mkl, scipack, etc.)

Parameters:
  • g1 (complex ndarray) – Fourier transform of reference image.

  • g2 (complex ndarray) – Fourier transform of the image to register (the kernel).

  • method (str, optional) – The correlation method to use. Must be ‘phase’ or ‘cross’ or ‘hybrid’ (default = ‘cross’)

  • upsample_factor (int) – Upsample factor for subpixel precision of cross correlation. (default = 1)

  • verbose (bool, default is False) – Print output.

Returns:

xyShift – The shift between G1 and G2 in pixels.

Return type:

list of floats

Example

Cross correlate two images already stored as ndarrays. You must input the FFT of the images.

>> import ncempy.algo as neval >> import numpy as np >> im0FFT = np.fft.fft2(im0) >> im1FFT = np.fft.fft2(im1) >> shifts = neval.multicorr(im0FFT, im1FFT)