imagehasher.py 文件源码

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

项目:Comictagger 作者: dickloraine 项目源码 文件源码
def average_hash(self):
        try:
            image = self.image.resize((self.width, self.height), Image.ANTIALIAS).convert("L")
        except Exception as e:
            sys.exc_clear()
            print "average_hash error:", e
            return long(0)

        pixels = list(image.getdata())
        avg = sum(pixels) / len(pixels)

        def compare_value_to_avg(i):
            return ( 1 if i > avg else 0 )

        bitlist = map(compare_value_to_avg, pixels)

        # build up an int value from the bit list, one bit at a time
        def set_bit( x, (idx, val) ):
            return (x | (val << idx))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号