images2gif.py 文件源码

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

项目:RasterFairy 作者: Quasimondo 项目源码 文件源码
def quantize_without_scipy(self, image):
        """" This function can be used if no scipy is availabe.
        It's 7 times slower though.
        """
        w,h = image.size
        px = np.asarray(image).copy()
        memo = {}
        for j in range(w):
            for i in range(h):
                key = (px[i,j,0],px[i,j,1],px[i,j,2])
                try:
                    val = memo[key]
                except KeyError:
                    val = self.convert(*key)
                    memo[key] = val
                px[i,j,0],px[i,j,1],px[i,j,2] = val
        return Image.fromarray(px).convert("RGB").quantize(palette=self.paletteImage())
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号