images2gif.py 文件源码

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

项目:CycleGAN-Tensorflow-PyTorch-Simple 作者: LynnHo 项目源码 文件源码
def quantize_with_scipy(self, image):
        w, h = image.size
        px = np.asarray(image).copy()
        px2 = px[:, :, :3].reshape((w * h, 3))

        cKDTree = get_cKDTree()
        kdtree = cKDTree(self.colormap[:, :3], leafsize=10)
        result = kdtree.query(px2)
        colorindex = result[1]
        print("Distance: %1.2f" % (result[0].sum() / (w * h)))
        px2[:] = self.colormap[colorindex, :3]

        return Image.fromarray(px).convert("RGB").quantize(palette=self.paletteImage())
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号