adafruit / Adafruit_TCS34725

Arduino library driver for Adafruit's TCS34725 RGB Color Sensor Breakout

Home Page:http://www.adafruit.com/products/1334

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gamma correction seems wrong

iZhangHui opened this issue · comments

The gamma correction calculation formula in colorview.ino seems not right.
`for (int i=0; i<256; i++) {

float x = i;

x /= 255;

x = pow(x, 2.5);

x *= 255;

`

I think it should be x = pow(x, 2.5); --> x = pow(x, 1/2.5);

It's an interesting issue, that would need to be studied.

At first, we must know what's the OETF (opto electronic transfer function) of a LED, from what I read, brightness is linear with current (here we're driving LED with voltage).
Then we could apply the correct EOTF (electro optical transfer function) and get a correct result.

Note that I'm not using the term "gamma", it's a too much global actually and means nothing.
I'll do some measures and report if you are interested.

In an RGB led datasheet (https://www.arduino.cc/documents/datasheets/LEDRGB-L-154A4SURK.pdf), we can see the current/voltage transfer curve. Search for the forward current vs. forward voltage chart.
So the I think a more correct EOTF would indeed be something like pow(x, 1/y), where y is still to find. We must also consider the voltage offset (at what voltage the LED starts to emit light)
RGBled curVSlum
EDIT : y seems to be close to 2.35