gamma correction seems wrong
iZhangHui opened this issue · 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);
@PaintYourDragon any thoughts?
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)
EDIT : y seems to be close to 2.35