如何将ImageHash转换为Numpy数组?

问题描述 投票:0回答:1
i使用python / imagehash.phash搜索类似于给定的照片,即照片,以使锤距为零。 现在,我也想检测到翻转或旋转副本的照片 - 锤距> 0。 我想直接从原始的phash中直接从旋转 /翻转照片的phash来计算新的phash。

let

hash = imagehash.phash(Image.open(photo_file))

在jupyter笔记本中,哈希是

0 f123b10e84aaf337 Name: C:\xxxx\B.jpg, dtype: object

hash [0]是

array([[ True, True, True, True, False, False, False, True], [False, False, True, False, False, False, True, True], [ True, False, True, True, False, False, False, True], [False, False, False, False, True, True, True, False], [ True, False, False, False, False, True, False, False], [ True, False, True, False, True, False, True, False], [ True, True, True, True, False, False, True, True], [False, False, True, True, False, True, True, True]]), imagehash.ImageHash

我的想法是将哈希人转换为numpy数组,使用np.flip等,然后将数组转换回phash.

问题:

我如何将哈希或哈希[0](看起来像一个数组)转换为一个numpy数组?
    有一种更好的方法来搜索原始照片哈希的旋转 /翻转图像?
  1. 从读取
sourcecode
python arrays numpy image phash
1个回答
0
投票
.hash

构建器的二进制数组之间转换。 imagehash.ImageHash()

输出:
from PIL import Image
import imagehash

img = Image.open("house.jpg")
image_hash_obj = imagehash.phash(img)
print(image_hash_obj)
hash_array = image_hash_obj.hash
print(hash_array)
hash_array[0, 0] = False
image_hash_obj2 = imagehash.ImageHash(hash_array)
print(image_hash_obj2)


最新问题
© www.soinside.com 2019 - 2025. All rights reserved.