machinevisiontoolbox.Image.ncc

Image.ncc(image2)

Normalised cross correlation

Parameters:

image2 (Image) – second image

Raises:

ValueError – image2 shape is not equal to self

Returns:

normalised cross correlation

Return type:

scalar

Returns an image similarity measure which is the normalized cross-correlation between the image and image2. The result is a scalar in the interval -1 (non match) to 1 (perfect match) that indicates similarity.

Example:

>>> from machinevisiontoolbox import Image
>>> img1 = Image([[10, 11], [12, 13]])
>>> img2 = Image([[10, 11], [10, 13]])
>>> img1.ncc(img2)
0.9970145759536657
>>> img1.ncc(img2+10)
1.395820406335132
>>> img1.ncc(img2*2)
1.2678511640312011
Note:
  • The ncc similarity measure is invariant to scale changes in image intensity.

References:
  • Robotics, Vision & Control for Python, Section 11.5.2, P. Corke, Springer 2023.

Seealso:

zncc sad ssd