Get quantitative value for color on two-color scale

怎甘沉沦 提交于 2019-12-13 08:06:10

问题


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:


  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:

    • RGB values of visible spectrum
    • Star B-V color index to apparent RGB color
  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:

    • Enhancing dynamic range and normalizing illumination

    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:

    • approximation search
    • LUT (look up table) to find 2 closest matches and interpolate
    • Reverse complex 2D lookup table

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



来源:https://stackoverflow.com/questions/35759355/get-quantitative-value-for-color-on-two-color-scale

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!