aws / dcv-color-primitives

DCV Color Primitives Library
MIT No Attribution
30 stars 22 forks source link

What does "Gamma-corrected RGB" in the docstring for ColorSpace::Lrgb mean? #63

Closed astraw closed 2 years ago

astraw commented 2 years ago

Hi I'm looking at this crate and see that the docstring for ColorSpace::Lrgb says "Gamma-corrected RGB". Can you describe a bit more what this colorspace is? I would guess that the "L" in "Lrgb" might stand for "linear", but then this would, by definition, not be gamma-corrected. If images in the Lrgb colorspace are indeed gamma-corrected and not-linear, what gamma value is expected? And what does "L" mean in that case? Thanks!

fabiosky commented 2 years ago

Hi Andrew,

Thanks for bringing to attention these details.

Here's the clarifications:

R' = 4.5 * R                     if R < 0.018,
R' = 1.099 * (R ^ 0.45) - 0.099  otherwise.

It is indeed true that chroma-subsampling is currently done by first scaling the R'G'B' image in gamma-space, then converting to YUV. A more correct approach would convert R'G'B' to linear RGB, scale RGB, convert back to R'G'B', finally convert to YUV. For now, we are sticking with the current approach because is faster than the second one, but an option would be to add a parameter to select the downsampling strategy (apart from gamma issues, current filtering is a mere box one, an area of improvement is to try different filters).

Action items for this issue would be:

Thanks, Fabio

fabiosky commented 2 years ago

All action items addressed since 0.5.0. Feel free to reopen for other clarifications.

Thanks, Fabio

astraw commented 2 years ago

Very nice, thank you very much. This is very clear.