Skip to content

Instantly share code, notes, and snippets.

@tshrinivasan
Created February 9, 2021 21:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tshrinivasan/3f51cf502610b429e24e2e66041bfd1f to your computer and use it in GitHub Desktop.
Save tshrinivasan/3f51cf502610b429e24e2e66041bfd1f to your computer and use it in GitHub Desktop.
compare images in python
import cv2
import numpy as np
def mse(imageA, imageB):
err = np.sum((imageA.astype("float") - imageB.astype("float")) ** 2)
err/=float(imageA.shape[0] * imageA.shape[1])
return err
original_testfigure1 = cv2.imread("testfigure1.png")
expected_testfigure1 = cv2.imread("testfigure2.png")
if(mse(original_testfigure1, expected_testfigure1) <=100.0 :
print("images are similar")
else:
print("images are not similar")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment