简体   繁体   English

比较两组(或调色板)colors 时是否有任何距离?

[英]Is there any distance when comparing two sets (or palettes) of colors?

When measuring color distance between two colors, there are plenty of methods.在测量两个colors之间的色距时,有很多方法。 You can use the euclidean distance in the RGB space and you can do more sophisticated calculation such as the perceptual distance in the Lab space (deletE).您可以在 RGB 空间中使用欧氏距离,并且可以进行更复杂的计算,例如 Lab 空间中的感知距离 (deletE)。

But I am asking if there exists any sort of distance that can be measured between a set of colors and another set of colors, which can be referred as palettes.但我想问的是,在一组 colors 和另一组 colors 之间是否存在可以测量的距离,这可以称为调色板。 In a first instance both sets could be of the same length, but ideally the set could contain any number of colors.在第一个实例中,两个集合的长度可能相同,但理想情况下,该集合可以包含任意数量的 colors。

Eg.例如。

set_1 = {(255, 0, 0), (200, 10, 10), (230, 20, 20)}
set_2 = {(255, 50, 50), (200, 50, 50)}
set_3 = {(0, 255, 0), (10, 255, 10)}

Intutively, the distance between set_1 and set_2 would be smaller than set_1 and set_3 .直觉上, set_1set_2之间的距离会小于set_1set_3 But I do not know if any method exists to have a quantitive approach to this problem.但我不知道是否存在任何方法可以对这个问题进行定量处理。

I have already tried measuring the distance of the main color of the palette, but I have not found a solution that takes into account all the colors from the sets.我已经尝试测量调色板主要颜色的距离,但我还没有找到一个解决方案,该解决方案考虑了集合中的所有 colors。

It won't be trivial, even with palettes exactly the same size.这不会是微不足道的,即使调色板大小完全相同。

An approach would be to convert RGB colors to YUV (CIE94 would be even better...), then substract the second palette from the first to obtain a vector of distances.一种方法是将 RGB colors 转换为 YUV(CIE94 会更好......),然后从第一个调色板中减去第二个调色板以获得距离向量。

Then, you can compute on this vector average value and the standard deviation: according to what you find, you will be able to say if palettes are "close" or "far" from each other.然后,您可以计算此向量的平均值和标准差:根据您发现的内容,您将能够判断调色板彼此“接近”还是“远离”。

This is already a lot of code to implement... But things become ugly with palettes of different sizes.这已经是很多要实现的代码了……但是对于不同大小的调色板,事情变得很难看。 How will you "extend" the shortest one to match the longest one's size?你将如何“扩展”最短的以匹配最长的尺寸?

A possibility could be to set a maximum palette size (let's say 256 colors), and to compute, for EACH compared palette, a 256-entries palettes computed as a regular and homogeneous gradient (compute it directly in YUV/CIE94, not in RGB).一种可能性是设置最大调色板大小(比如 256 种颜色),并为每个比较的调色板计算 256 个条目的调色板计算为规则和均匀的渐变(直接在 YUV/CIE94 中计算,而不是在 RGB 中计算).

You can then test the two extended palettes with the previous method.然后您可以使用前面的方法测试两个扩展的调色板。 But you'll probably have a lot of false positives until you find correct parameters to "calibrate" your algorithm to expand palettes... Maybe go for even larger palettes (1024?) and shrink them with an "antialias" that will merge adjacent colors, once gradient is computed, to reduce rounding errors?但是你可能会有很多误报,直到你找到正确的参数来“校准”你的算法以扩展调色板......也许 go 对于更大的调色板(1024?)并使用将合并相邻的“抗锯齿”缩小它们colors,计算梯度后,减少舍入误差?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM