我目前正在尝试在Python中从图像中获取哈希值,我已经成功完成并且它有点起作用。
然而,我遇到了这个问题:
尽管Image1和Image2是不同的,它们最终具有相同的哈希值。我需要一种更精确的哈希方式。
Image1 = Image1
Image2 = Image2
图像的哈希值为:faf0761493939381
我目前正在使用from PIL import Image
import imagehash
以及imagehash.average_hash
代码在此处
import os
from PIL import Image
import imagehash
def checkImage():
for filename in os.listdir('images//'):
hashedImage = imagehash.average_hash(Image.open('images//' + filename))
print(filename, hashedImage)
for filename in os.listdir('checkimage//'):
check_image = imagehash.average_hash(Image.open('checkimage//' + filename))
print(filename, check_image)
if check_image == hashedImage:
print("Same image")
else:
print("Not the same image")
print(hashedImage, check_image)
checkImage()