Skip to content

Instantly share code, notes, and snippets.

@nimpy
Last active November 4, 2022 08:29
Show Gist options
  • Save nimpy/54ccb199c978a5074cdcd35fc696a904 to your computer and use it in GitHub Desktop.
Save nimpy/54ccb199c978a5074cdcd35fc696a904 to your computer and use it in GitHub Desktop.
Computing the sum of squared differences (SSD) between two images.
import numpy as np
def calculate_ssd(img1, img2):
"""Computing the sum of squared differences (SSD) between two images."""
if img1.shape != img2.shape:
print("Images don't have the same shape.")
return
return np.sum((np.array(img1, dtype=np.float32) - np.array(img2, dtype=np.float32))**2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment