如何比较两种颜色的相似性/差异性 [英] How to compare two colors for similarity/difference

查看:25
本文介绍了如何比较两种颜色的相似性/差异性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设计一个程序来帮助我在 5 种预定义颜色之间进行评估,哪个更类似于可变颜色,以及百分比.问题是我不知道如何手动一步一步地做到这一点.所以想一个程序就更难了.

更多细节:颜色来自不同颜色的凝胶管照片.我有 5 个不同颜色的管子,每个管子代表 5 个级别中的 1 个.我想拍摄其他样品的照片,并在计算机上通过比较颜色来评估该样品属于哪个级别,我也想知道近似值的百分比.我想要一个程序可以做这样的事情:http://www.colortools.net/color_matcher.html>

如果您能告诉我要采取哪些步骤,即使它们是我需要手动思考和完成的事情.这将非常有帮助.

解决方案

参见维基百科关于色差 为正确的线索.基本上,您想在某个多维色彩空间中计算距离度量.

但是 RGB 不是 感知上统一的",因此 Vadim 建议的欧几里得 RGB 距离度量与人类感知的不匹配颜色之间的距离.首先,L*a*b* 旨在成为感知统一的色彩空间,并且通常使用 deltaE 度量.但还有更精细的色彩空间和更精细的 deltaE 公式,它们更接近于匹配人类感知.

您必须了解有关色彩空间和光源的更多信息才能进行转换.但是对于比欧几里德 RGB 度量更好的快速公式,只需执行以下操作:

计算成本并不高,只是一些非线性公式和一些乘法和加法.

I want to design a program that can help me assess between 5 pre-defined colors which one is more similar to a variable color, and with what percentage. The thing is that I don't know how to do that manually step by step. So it is even more difficult to think of a program.

More details: The colors are from photographs of tubes with gel that as different colors. I have 5 tubes with different colors were each is representative of 1 of 5 levels. I want to take photographs of other samples and on the computer assess to which level that sample belongs by comparing colors, and I want to know that with a percentage of approximation too. I would like a program that does something like this: http://www.colortools.net/color_matcher.html

If you can tell me what steps to take, even if they are things for me to think and do manually. It would be very helpful.

解决方案

See Wikipedia's article on Color Difference for the right leads. Basically, you want to compute a distance metric in some multidimensional colorspace.

But RGB is not "perceptually uniform", so your Euclidean RGB distance metric suggested by Vadim will not match the human-perceived distance between colors. For a start, L*a*b* is intended to be a perceptually uniform colorspace, and the deltaE metric is commonly used. But there are more refined colorspaces and more refined deltaE formulas that get closer to matching human perception.

You'll have to learn more about colorspaces and illuminants to do the conversions. But for a quick formula that is better than the Euclidean RGB metric, just do this:

  • Assume that your RGB values are in the sRGB colorspace
  • Find the sRGB to L*a*b* conversion formulas
  • Convert your sRGB colors to L*a*b*
  • Compute deltaE between your two L*a*b* values

It's not computationally expensive, it's just some nonlinear formulas and some multiplications and additions.

这篇关于如何比较两种颜色的相似性/差异性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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