Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

luma/luminance named incorrectly? #2829

Closed
xi opened this issue Mar 3, 2016 · 9 comments
Closed

luma/luminance named incorrectly? #2829

xi opened this issue Mar 3, 2016 · 9 comments

Comments

@xi
Copy link

xi commented Mar 3, 2016

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.

  • Luma is calculated from gamma encoded RGB values, which AFAIU are the values we usually work with in web design.
  • Luminance on the other hand is calculated from the RGB values a user actually sees, which can be at least approximated by manually applying sRGB gamma decoding.

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
Copy link
Member

Synchro commented Mar 3, 2016

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
Copy link
Author

xi commented Mar 3, 2016

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
Copy link
Member

Synchro commented Mar 3, 2016

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
Copy link
Member

Synchro commented Mar 3, 2016

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
Copy link
Member

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
Copy link
Member

Closing as not an issue.

@xi
Copy link
Author

xi commented Mar 27, 2016

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
Copy link

Hi Xi, I am researching. Thanks, Moe

@Myndex
Copy link

Myndex commented Apr 25, 2019

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:

  • Luminance Y at 18.4 is the middle grey that people pick as being "in between black and white."
  • With L* that is 50 (the perceptual midpoint)
  • sRGB video "luma" Y´, about 46.65% unless you account for the "system gamma gain".

This is part of WCAG issue 695.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants