functions.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:scene_detection 作者: VieVie31 项目源码 文件源码
def dhash(img):
    """Compute a perceptual has of an image.

    Algo explained here :
    https://blog.bearstech.com/2014/07/numpy-par-lexemple-une-implementation-de-dhash.html

    :param img: an image

    :type img: numpy.ndarray

    :return: a perceptual hash of img coded on 64 bits
    :rtype: int
    """
    TWOS = np.array([2 ** n for n in range(7, -1, -1)])
    BIGS = np.array([256 ** n for n in range(7, -1, -1)], dtype=np.uint64)
    img = rgb2grey(resize(img, (9, 8)))
    h = np.array([0] * 8, dtype=np.uint8)
    for i in range(8):
        h[i] = TWOS[img[i] > img[i + 1]].sum()
    return (BIGS * h).sum()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号