less / less.js

Less. The dynamic stylesheet language.
http://lesscss.org
Apache License 2.0
17k stars 3.41k forks source link

luma/luminance named incorrectly? #2829

Closed xi closed 8 years ago

xi commented 8 years ago

I am not completely sure about this, but if I undestand this document and this article correctly, the names of luma and luminance need to be swapped.

I understand that fixing this would be a breaking change. However, I feel that less is an important reference for web designers getting into color theory, so fixing this could prevent a lot of confusion.

Synchro commented 8 years ago

No, in the Less code, luma is correct as it is the gamma-weighted sum of RGB components, and we use the W3C spec for that calculation. Luminance is implemented as the non-gamma-corrected values, which is a somewhat more arbitrary calculation, more like what you get as the L component of HSL.

xi commented 8 years ago

The spec is rather blurry on the naming because it calls it "relative luminance" in one place and "relative brightness" on the next line. "Luma" is not mentioned at all. So the question comes down to this: Is the spec actually refering to luma (then the current naming in Less would be correct) or is it using the right word?

One major source of confusion for me is the term "gamma correction/compression". Does it refer to the encoding or the decoding step? And which of these is the one described in the spec?

Here is a quote from wikipedia:

For RGB color spaces that use the ITU-R BT.709 primaries (or sRGB, which defines the same primaries), relative luminance can be calculated from linear RGB components:

Y = 0.2126 R + 0.7152 G + 0.0722 B

Reading this again closely I get the impression that you are right and the spec is wrong. The RGB colors we usually use are in the sRGB color space (multiplied by 255), so the relative luminance can be calculated with the above formular. The spec says that you have to apply some non-linear conversion first, so it is most definitely refering to luma.

But I am still very confused.

Do you think I should file a bug report with https://github.com/w3c/wcag/?

Synchro commented 8 years ago

No, it's correct - that relative luminance is what we're calling luminance. luma uses the same coefficients, but applied to gamma-corrected RGB values rather than the linear ones. sRGB defines the gamma transform that's applied, which you can see in the less luma code. You'll see the luma calc written like this:

Y' = 0.2126 R' + 0.7152 G' + 0.0722 B'

The ' is used to denote non-linear values, i.e. the gamma corrected versions - as that wikipedia page says:

Note that relative luminance should not be confused with luma, the weighted sum of the nonlinear gamma compressed R'G'B' components

In short, there's nothing to worry about...

Synchro commented 8 years ago

Actually, I see what you mean about the WCAG page - it does refer to gamma-corrected luminance (i.e. luma) as relative luminance. The luminance wikipedia page is clearer in its definitions, and agrees with what Less does.

seven-phases-max commented 8 years ago

Yes, I guess we discussed the naming when it was implemented in #1890. And it looks more to be correct as it is now (after all it's all about more a common convention and that's where WCAG wordings are not always issue free :). So I guess it's safe to close this.

seven-phases-max commented 8 years ago

Closing as not an issue.

xi commented 8 years ago

I sent a mail to w3c-wai-ig@w3.org and wanted to wait for that discussion before closing this issue. Unfortunately I did not get much response.

moekraft commented 7 years ago

Hi Xi, I am researching. Thanks, Moe

Myndex commented 5 years ago

Hi @xi hi @moekraft

Just to mention, the W3C/WCAG is in error in some of the explanations, a fact I am working to correct in WCAG issue 695 among others.

Super fast summary:

Luminance (Y of CIEXYZ) is LINEAR with no gamma correction. It is NOT perceptually uniform, it is linear like light in the real world. It IS spectrally weighted, so the tristimulus values (R G B) fit to human perception, but the total measure from black to white is linear.

Luma (Y´that is, y-prime) has a gamma curve applied for the video system it is used with.

L is perceptual lightness, a perceptually uniform curve that is part of CIELAB and CIELUV. L a b is a perceptually uniform colorspace.

0 and 100 are essentially the same for Y, Y´and L*, but the values in between vary greatly due to the different curves.

For a scale 0 to 100:

This is part of WCAG issue 695.

Read Charles Poynton's Gamma FAQ and Color FAQ for a great start on a complicated topic.