correlation_function

correlation_function#

scarlet2.measure.correlation_function(img, maxlength=12, threshold=None, mask=None)[source]#

Computes the 2D correlation function of the image.

Uses per-channel jit-compiled calls to the 2D correlation function for performance.

Parameters:
  • img (numpy.ndarray) – Image array, 2D or 3D.

  • maxlength (int) – Maximum length of the correlation function. It needs to be large enough to cover the extent of the correlations, otherwise the derived power spectrum is biased. img should be substantially larger, so that every lag is still averaged over many pixel pairs.

  • threshold (float, optional) – Minimum correlation coefficient to maintain. Clipping is a non-linear operation that destroys the positive semi-definiteness of the correlation function, and with it the non-negativity of the power spectrum derived from it, so it is off by default.

  • mask (numpy.ndarray, optional) – Boolean array (same shape as img, or 2D broadcast over the channels) marking invalid pixels. A pixel pair is only counted at a given lag if neither of its pixels is masked, so xi is an unbiased pairwise estimate regardless of mask geometry. If None, pixels that are exactly zero in img are treated as masked.

Return type:

dict, with keys (dy,dx) specifying the 2D offset in image pixels