Adafruit_TCS34725 icon indicating copy to clipboard operation
Adafruit_TCS34725 copied to clipboard

gamma correction seems wrong

Open iZhangHui opened this issue 6 years ago • 3 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);

iZhangHui avatar Mar 07 '19 03:03 iZhangHui

@PaintYourDragon any thoughts?

ladyada avatar Mar 07 '19 16:03 ladyada

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.

cedricp avatar May 27 '19 09:05 cedricp

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

cedricp avatar May 27 '19 10:05 cedricp