我正在运行下面的代码来删除均匀色块之间不需要的渐变。这在很多情况下都能很好地工作,但是有时会失败,因为一些渐变色和调色板颜色很相似,比如下面的图像(top=original,bottom=result,right=palete image)。我怎么能避免呢?你知道吗
from PIL import Image
import os
path_images = "D:/RasterCalc/Samples_Original"
path_palette = "D:/RasterCalc/Palettes/palette_nsph.png"
path_output = "D:/RasterCalc/Samples_Converted"
image_palette = (Image.open(path_palette)).convert('RGBA')
image_palette = image_palette.convert('P')
for filename in os.listdir(path_images):
image = (Image.open(path_images+"/"+filename)).convert('RGB')
print(filename)
image_converted = image.quantize(palette=image_palette)
image_converted.save(path_output+"/"+filename)
print("==================")
print("done!")
/edit:现在用一些圆圈来澄清!你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐