比较C#RGB颜色 [英] Compare RGB colors in c#
问题描述
我试图找到一种方法来比较两种颜色,找出多少,他们都是一样的。我似乎无法找到有关这个问题,所以我希望能在这里得到一些指点的任何资源。
I'm trying to find a way to compare two colors to find out how much they are alike. I can't seem to find any resources about the subject so I'm hoping to get some pointers here.
Idealy,我想获得一个分数,告诉多少,他们都是一样的。例如,0到100,其中100将等于0将是完全不同的。
Idealy, I would like to get a score that tells how much they are alike. For example, 0 to 100, where 100 would be equal and 0 would be totally different.
谢谢!
编辑:
开始了解多一点有关从颜色答案我明白我的问题有点含糊。我会尽量解释什么,我需要的本作。
Getting to know a bit more about colors from the answers I understand my question was a bit vague. I will try to explain what I needed this for.
我在800x600尺寸的应用程序窗口PixelData取出(位置和颜色),所以我可以找出某个窗口是通过检查每X间隔开与否。
I have pixeldata (location and color) of an application window at 800x600 size so I can find out if a certain window is open or not by checking every x-interval.
然而,这种方法,一旦应用程序被调整大小(将缩放内容,不移动)失败。我可以计算出在哪里像素移动,但由于四舍五入和antialising颜色可以稍微不同的。
However, this method fails as soon as the application is resized (the contents are scaled, not moved). I can calculate where the pixels move, but because of rounding and antialising the color can be slightly different.
彼得的解决方案是在这种情况下,足以让我好,虽然所有其他的反应是非常有益的,以及,所以我只是upvoted大家。我认为ColorEye的回答是最准确的在这个从专业的方式看时,让我将其标记为答案。
Pieter's solution was good enough for me in this case, although all other responses were extremely helpfull as well, so I just upvoted everyone. I do think that ColorEye's answer is the most accurate when looking at this from a professional way, so I marked it as the answer.
推荐答案
你所寻找的是一个名为三角洲-E
。
What you are looking for is called Delta-E
.
<一个href=\"http://www.colorwiki.com/wiki/Delta_E:_The_Color_Difference\">http://www.colorwiki.com/wiki/Delta_E:_The_Color_Difference
有在LAB色彩空间中的两个颜色之间的距离。有人说,人眼无法分辨低于1的DeltaE颜色(我发现我的眼睛可以找到低于1的DeltaE颜色的差异,每个人都是不同的。)
It is the distance between two colors in LAB color space. It is said that the human eye cannot distinguish colors below 1 DeltaE (I find that my eyes can find differences in colors below 1 DeltaE, each person is different.)
有4公式色差。
- 的ΔE(CIE 1976)
- 的ΔE(CIE 1994)
- 的ΔE(CIE 2000)
- 三角洲E(CMC)
检查本网站上的链接数学:
Check the math link on this site:
- http://www.brucelindbloom.com/
所以,正确的答案是使用的公式,以你的RGB转换为LAB,然后用1976年的DeltaE来确定你的颜色'差异'。 0结果将显示相同的颜色。任何值高于0可以通过规则小于或等于1是大多数人难以区分的ΔE'来判断。
So the proper answer is to convert your RGB to LAB using the formula given, then use DeltaE 1976 to determine the 'difference' in your colors. A result of 0 would indicate identical colors. Any value higher than 0 could be judged by the rule 'A delta e of 1 or less is indistinguishable by most people'.
这篇关于比较C#RGB颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!