I'm making a color analyzer which can measure Red, Green, and Blue portions of a color (ex: 128,255,0).I'm not supposed to use pre-made color sensors and need 1% ACCURACY.

I used three LEDs - R,B & B to sequentially measure the values. When green led is on. the reflection is caught by the photo-transistor. The deviation of voltage is converted to current deviation using OPAMP's V to I circuit so that intensity of green reflection can be measured and can be calibrated to show a 0-255 value using a micro-controller.

I was successful in measuring green value of a color only if the color contained green potions. (ex [0,255,0] , [0,128,0], [0,200,0] ). likewise I can get RGB values only if one color is present. If I was given a color which is a combination of R,G,B then the voltage reading is different and wrong. For example I get a higher voltage (higher intensity) when I'm measuring white (255,255,255) than green (0,255,0). Ideally I should have got the same amount of green because those colors had same amount of green - 255.

What is the cause of the problem and how can I use an alternating method to achieve my target? Is there a method to separate the reflection in to R,G,B with high accuracy? Thanks in advance. ( I'm using a Photoshop print on a matte photo print paper as the color)

EDIT: The 3 LED's and the photo-transistor is fully covered making sure that no background light will not interfere.

  • \$\begingroup\$ Have you tried measuring the amount of C, M, and Y instead? \$\endgroup\$ Jul 6, 2015 at 3:03
  • \$\begingroup\$ @IgnacioVazquez-Abrams I don't really understand how it can help me. I'm really pleased if you can elaborate it quite further. Thank you \$\endgroup\$ Jul 6, 2015 at 3:11
  • \$\begingroup\$ "I'm not supposed to use pre-made color sensors" - just out of interest, why not? \$\endgroup\$ Jul 6, 2015 at 4:45
  • \$\begingroup\$ What kind of samples are you testing? (How do you know your [255,255,255] sample really has the same reflectivity in green as your [0,255,0] sample?) \$\endgroup\$
    – The Photon
    Jul 6, 2015 at 4:59
  • \$\begingroup\$ 1% accuracy? In what controlled environment, in what lighting situation? You're not going to get even close with any random setup... You need to at least control lighting and have a calibration phase for every different LED, diode pairing. Printing out colors isn't going to work with any random printer either... \$\endgroup\$
    – FRob
    Jul 6, 2015 at 7:52

2 Answers 2


To understand the results you are getting you have to consider the spectral response curves of your light source, detector, and the object being measured. The final result is a combination of all these 'filters' acting on the signal. And if you want to relate that to the colors you see, then you also have to take into account the spectral response of the human eye.

I'm using a Photoshop print on a matte photo print paper as the color

A photographic print is calibrated to show correct colors when viewed by the human eye. This does not mean that it will reflect all the color components in direct proportion to the values in the digital image. The pigments or dyes used in color printers don't produce pure colors. A perfect 'green' ink (which is actually a combination of cyan and yellow) would reflect all wavelengths between 495 and 570nm ('green') while absorbing all other wavelengths in the visible spectrum ('blue' and 'red'). But practical inks do not have such sharp response, so 'green' ink won't reflect all green light, and may also have some blue and red in it.

To compensate for the color being too dark the printer may lay down less ink to let more of the white paper show through. But traces of blue and red in the 'green' could make it look muddy or washed out, which the printer may compensate for by adding black. The printer may also alter color ratios to get a more accurate hue. The end result looks alright, but is not an exact match to the digital RGB value of 0,255,0. What you are seeing is not actually pure green, but a mixture of many different colors that just look like pure green to the human eye.

Another factor to consider is the spectral output of your LEDs. Most green LEDs emit a fairly narrow band of green light, If this doesn't line up with the ink's spectral response then the output could be lower than expected. If you then calibrate to this lower value and call it '255', a pure white image could read higher than expected because the plain white paper reflects more wavelengths of green light than the 'green' ink does.

Finally, the detector's response could be distorting the results. Standard photo-transistors peak in the near infra-red, and response drops off rapidly towards the blue end of the spectrum. This could skew the response so that 'yellow' green produces a higher reading than 'blue' green.

Bottom line:- the printer modifies the image's RGB values to produce a result that looks right to the human eye, so to get a meaningful result your emitter/detector combination must replicate the spectral response of the human eye. Even then, the results won't exactly match the RGB color values in the digital image (1%? forget about it!).

enter image description here

enter image description here

enter image description here

enter image description here

  • \$\begingroup\$ Thank you very much for the answer and Now I have a good understanding of what's wrong. But I wonder how the RGB sensors work. \$\endgroup\$ Jul 6, 2015 at 16:22
  • \$\begingroup\$ RGB sensors typically use 3 silicon photodiodes with individual red, green, and blue filters. Some also have a front filter with a blue cast, which equalizes the RGB response and cuts out infrared. Here's an example:- hamamatsu.com/jp/en/product/alpha/R/4153/S7505-01/index.html. By carefully choosing filter materials and densities the spectral response can be tailored to specific applications. \$\endgroup\$ Jul 6, 2015 at 17:59

"those colors had same amount of green"

That's probably not quite true. "Green" to your detector is not "any" green, but follows the emission spectrum of the green LED. See e.g. https://en.wikipedia.org/wiki/Light-emitting_diode#/media/File:Red-YellowGreen-Blue_LED_spectra.png. Notice how the green emission ranges from ~520 to ~680nm. To get max green brightness on your sensor, the surface would have to reflect that whole spectrum. White does so, most kinds of "green" don't.

Probably, the easiest way to handle this is to do your own series of calibration measurements. Print a dozen or so of different colors from the spectrum you're interested in and record the values your sensor delivers for each of them. From that, you can interpolate the tones between. This way you get a calibration for your specific types of LEDs, filters, and photosensor without having to gather and combine all numbers from the datasheets for a theoretical model.

  • \$\begingroup\$ Thank you very much. I wonder how RGB sensors are made though. XD \$\endgroup\$ Jul 6, 2015 at 16:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.