Python - Image Processing

Check if the images are the same.

from PIL import Image
import math
import operator
from functools import reduce
def image_contrast(img1, img2):
image1 = Image.open(img1)
image2 = Image.open(img2)
h1 = image1.histogram()
h2 = image2.histogram()
result = math.sqrt(reduce(operator.add,  list(map(lambda a, b: (a-b)**2, h1, h2)))/len(h1))
return result
if __name__== '__main__':
img1 = "./1.jpeg"  #specify image path 
img2 = "./2.jpeg"
result = image_contrast(img1, img2)
print(result)
#link :https://www.zhihu.com/question/399653758/answer/1270904317

Exploration of Image Similarity Algorithms and Analysis of Applicable Scenarios in Image Processing https://zhuanlan.zhihu.com/p/94081111.