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())
images2gif.py 文件源码
python
阅读 26
收藏 0
点赞 0
评论 0
评论列表
文章目录