【发布时间】:2013-10-23 17:12:18
【问题描述】:
我正在使用 Python 中的一个程序来创建十字绣方案,并且需要将图像中的颜色减少为特定的牙线颜色 like this。不必使用牙线调色板中的所有颜色。 在 Python 或伪代码上。
自定义调色板(例如在 PILL/Pillow 中)不合适。最多有 256 种颜色,但牙线调色板大约有 450 种颜色,我计划使用来自不同制造商的多种颜色图表。
抖动也不适用于十字绣。
我认为这可能是这样的:
result = []
for pixel_color in image:
nearest = None
for floss_color in floss_palette:
distance = delta_e_cie2000(pixel_color, floss_color)
if distance < nearest:
nearest = floss_color
result.append(nearest)
可能有更快的算法吗? (image_width * image_heigh * 调色板中的颜色 = 112M delta_e 计算和比较平均 500x500px 图像。很多。)
已经计算的 delta_e 的字典?另一种算法/方法/优化?
【问题讨论】:
-
memoize - 你不需要重新测试你已经完成的颜色
标签: python algorithm image-processing python-imaging-library color-palette