Last active
November 4, 2022 08:29
-
-
Save nimpy/54ccb199c978a5074cdcd35fc696a904 to your computer and use it in GitHub Desktop.
Computing the sum of squared differences (SSD) between two images.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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