在双色标度上获得颜色的定量值 [英] Get quantitative value for color on two-color scale

查看:233
本文介绍了在双色标度上获得颜色的定量值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我进行了一项化学测试,根据样品中给定化学物质的多少,产生一种颜色。如果没有化学物质,则为绿色,如果存在饱和化学物质,则为黄色。我使用我的相机拍摄了几个样品,并开发了一个标准曲线,其中我添加了已知量的化学物质进行测试,并拍摄结果的照片,以将我的样品的结果与这些标准的颜色进行比较。



我想要做的是开发一个创建双色比例的算法。一种颜色是没有任何化学品(绿色)的测试,另一种颜色是用化学品(黄色)饱和的测试。然后当我输入一个样本颜色,算法给我一个%黄色输出。



我已经看到人们尝试在颜色之间创建一个渐变,但从来没有读过有人试图将颜色放在渐变上。



我已经能够得到我所有的样本的RGB颜色值,所以actaul算法是相当独立的任何编程语言(虽然我熟悉C,C# ,VBA和python)。



有人可以指定一个资源来做我想做的事吗?



谢谢,



Michael

解决方案


  1. 创建表格/函数 RGB = f(浓度)



    这是你想做的事情的相反。想法是将一些连续的标量变量( concentration )转换为 RGB 颜色(有一些物理意义)。这里有一些例子:






    • 现在选择角标记,计算它们如何与您的标记真实颜色不同,并内插整个图像双线性。如果你需要双立方(更好的结果),然后使用16标记。此过程与此非常相似:





      您需要尝试使用什么标记绿色和黄色或黑色&红色&绿色&蓝色或组合...),所以你的结果将保持相同的不同光线条件。此外,你必须进行依赖性镜头,你将#1 再次使用标记,因为没有它们你可能会有结果中的错误...



      只有您的相机经过预校准,指示器始终具有相同的颜色,材质,粗糙度,光亮度等,才能避免校准步骤...并且图像是在均匀恒定的照明条件下拍摄的(在某些框内,相同的灯泡,相同的博览会,相同的瞳孔...)没有任何阴影,斑点等。这样的设置是非常昂贵。低成本手持装置的价格约为$ 10000美元(通常用于在制造过程中进行颜色检测/测试以校准机器)。


    • 转换 concentration = f(RGB)



      1 是一种简单的函数,那么你可以使其反向代数并直接使用它。如果您在链接的质量检查中构建 RGB 图表,您将看到用作输入的渠道(有时只需要一个)。



      如果依赖关系太复杂或不是函数,则可以使用:




      • a href =http://stackoverflow.com/q/29166819/2521214>近似搜索

      • LUT (查找表)找到2个最接近的匹配项和interpolate

      • 颠倒复杂2D查找表



      如果依赖关系严格不增加非减少 binary-search



I have run a chemical test that produces a color depending on how much of a given chemical is in the sample. It is green if there is no chemical, and yellow if there is a saturating amount of chemical. I have used my camera to take pictures of several samples, and also developed a standard curve, where I add known amounts of chemical to the test, and take pictures of the results to compare the color of the result of my sample to these standards.

What I would like to do, is develop an algorithm that creates a two-color scale. One color is the test without any chemical (green), and the other color is the test saturated with chemical (yellow). And then when I input a sample color, the algorithm gives me a % Yellow output.

I have seen people try to create a gradient between to colors, but never read of someone trying to place colors onto that gradient.

I am already able to get the RGB color values of all my samples, so the actaul algorithm is fairly independent of any programming language (although I am familiar with C, C#, VBA, and python).

Can someone point me to a resource to do what I want to do?

Thank you,

Michael

解决方案

  1. create table/function RGB = f(concentration)

    It is the opposite of what you want to do. The idea is to convert some continuous scalar variable (concentration) to RGB color (with some physical meaning). Here some examples of mine for this:

  2. Camera calibration

    As Mark Ransom suggested this step is necessary. I would try to place some markers in the view area to help with this. For example something like:

    Now pick the colors in the corner markers, compute how match they differ to your marker real colors and interpolate the whole image bilinear-ly. If you need bi-cubic (much better results) then use 16 markers. This process is very similar to this:

    You will need to experiment what markers to use (just black&white, or just green&yellow or black&red&green&blue or combinations ...) so your results will keep the same for varying light conditions. Also you have to make the dependency shots you will base the #1 on again with markers because without them you could have errors in results ...

    Calibration step can be avoided only if your camera is pre-calibrated, the indicator is always the same color,material,roughness,shininess,... and the image is taken with uniformly constant illumination conditions (inside some box,same bulbs,same exposition,same pupil...) without any shadows,spots,etc... Setups like that are very expensive. The low cost hand held devices are around $10000 USD (usually used for color detection/testing in manufacturing to calibrate machines).

  3. conversion concentration = f(RGB)

    If the dependency in #1 is some kind of simple function then you can make its inverse algebraically and use it directly. If you construct the RGB diagrams as in the linked QA's you will see which channel(s) to use as input (sometimes you need just one).

    If the dependency is too complicated or not a function then you can use:

    In case the dependency is strictly non-increasing or non-decreasing you can also use binary-search for this.

这篇关于在双色标度上获得颜色的定量值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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