def phash64(img):
"""Compute a perceptual hash of an image.
:param img: a rgb image to be hashed
:type img: numpy.ndarray
:return: a perceptrual hash of img coded on 64 bits
:rtype: int
"""
resized = rgb2grey(resize(img, (8, 8)))
mean = resized.mean()
boolean_matrix = resized > mean
hash_lst = boolean_matrix.reshape((1, 64))[0]
hash_lst = list(map(int, hash_lst))
im_hash = 0
for v in hash_lst:
im_hash = (im_hash << 1) | v
return im_hash
评论列表
文章目录