我使用一条简单的线,使用
import numpy as np
from PIL import Image
im = Image.open('')
palette = np.array(im.getpalette(),dtype=np.uint8).reshape((256,3))
#####################
Printed result
[[ 1 3 0]
[ 2 4 1]
[ 28 0 4]
[ 20 2 26]
[ 24 5 18]
[ 33 7 22]
[ 36 7 12]
[ 0 20 18]
[ 42 15 16]
[ 43 18 30]
。。。等
打印“调色板”将颜色列为从索引0开始列出的RGB值。索引0通常为深色或黑色。在某些引擎中,它用于alpha透明。我想使用常用的透明度颜色,如洋红255 0 255
我想将我的每个png文件放在一个文件夹中并进行批处理(我必须手动将颜色添加到图像中,然后将它们保存为8位,以便颜色成为调色板的一部分),然后执行以下操作:
我想你想要这样的东西:
您可能会将其编码为在命令行上接受多个文件,如下所示:
然后你可以跑:
相关问题 更多 >
编程相关推荐