Created
February 9, 2021 21:24
-
-
Save tshrinivasan/3f51cf502610b429e24e2e66041bfd1f to your computer and use it in GitHub Desktop.
compare images in python
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 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