检查颜色相似性的算法 [英] Algorithm to check similarity of colors

查看:30
本文介绍了检查颜色相似性的算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种算法来比较两种 RGB 颜色并生成它们的相似性值(其中相似性意味着与人类的平均感知相似").

I'm looking for an algorithm that compares two RGB colors and generates a value of their similarity (where similarity means "similar with respect to average human perception").

有什么想法吗?

编辑:

由于我不能再回答了,我决定将我的解决方案"作为对问题的编辑.

Since I cannot answer anymore I decided to put my "solution" as an edit to the question.

我决定在我的应用程序中使用一个(非常)小的真彩色子集,以便我可以自己处理颜色的比较.我使用大约 30 种颜色并在它们之间使用硬编码距离.

I decided to go with a (very) small subset of true-color in my app, so that I can handle comparison of colors by my own. I work with about 30 colors and use hard-coded distances between them.

因为它是一个 iPhone 应用程序,我使用了 Objective-C 并且实现或多或少是一个表示下表的矩阵,它显示了颜色之间的距离.

Since it was an iPhone app I worked with objective-C and the implementation is more or less a matrix representing the table below, which shows the distances between the colors.

推荐答案

RGB 距离 in欧几里德空间与人类的平均感知"不太相似.

RGB distance in the euclidean space is not very similar to "average human perception".

您可以使用 YUV 色彩空间,它考虑了这个因素:

You can use YUV color space, it takes into account this factor :

 |  Y' |     |  0.299     0.587    0.114   | | R |
 |  U  |  =  | -0.14713  -0.28886  0.436   | | G |
 |  V  |     |  0.615    -0.51499 -0.10001 | | B |

您也可以为此使用 CIE 色彩空间.

You can also use the CIE color space for this purpose.

我将提到 YUV 色彩空间是一种廉价的近似值,可以通过简单的方法计算公式.但它在感知上并不统一.感知均匀意味着颜色值的相同数量的变化应该产生大致相同的视觉重要性的变化.如果您需要更精确和严格的指标,您一定要考虑 CIELAB 色彩空间或其他感知均匀空间(即使没有简单的转换公式).

I shall mention that YUV color space is an inexpensive approximation that can be computed via simple formulas. But it is not perceptually uniform. Perceptually uniform means that a change of the same amount in a color value should produce a change of about the same visual importance. If you need a more precise and rigourous metric you must definitely consider CIELAB color space or an another perceptually uniform space (even if there are no simple formulas for conversion).

这篇关于检查颜色相似性的算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆