cv2ext.metrics package

Module contents

Submodule containing tools for working with image metrics.

Functions

ncc()

Compute the normalized cross-correlation between two images.

cv2ext.metrics.ncc(image1: ndarray, image2: ndarray, size: tuple[int, int] | None = (112, 112), *, resize: bool | None = True) float[source]

Compute the normalized cross-correlation between two images.

Parameters:
  • image1 (np.ndarray) – The first image. Can be color or grayscale. Converted to grayscale if color.

  • image2 (np.ndarray) – The second image. Can be color or grayscale. Converted to grayscale if color.

  • size (tuple[int, int], optional) – The size to resize the images to, by default (112, 112). If None, the images are not resized.

  • resize (bool, optional) – If True, the images are resized to the given size before computing the correlation, by default False.

Returns:

The normalized cross-correlation between the two images.

Return type:

float

Raises:

ValueError – If the images are not the same size and not resizing.