小编Log*_*gan的帖子

Python 图像哈希

我目前正在尝试从 python 中的图像获取哈希值,我已经成功地完成了此操作并且它在某种程度上有效。

但是,我有这个问题:Image1 和 image2 最终具有相同的哈希值,即使它们不同。我需要一种更准确和精确的散列形式。

图像 1 =图像 1

图像2 =图像2

图像的哈希值是: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()
Run Code Online (Sandbox Code Playgroud)

python hash

8
推荐指数
1
解决办法
1万
查看次数

标签 统计

hash ×1

python ×1