-
Notifications
You must be signed in to change notification settings - Fork 92
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
L*a*b* <-> sRGB conversions? #39
Comments
Hi @mceachen, not all colors that can be described in L* a* b* are displayable, and it's expected for the R/G/B channels to go out of the normal bounds. This color picker can give you a sense of when the colors get clipped. |
Yep, think this should be considered duplicate of #33. Also, it’s my understanding there’s no strict range to the allowed values in Lab space since it depends on your display gamut. |
OK, I'm clamping values. FWIW it seems that, with clamping, the RGB results match other implementations: https://www.wolframalpha.com/input/?i=CIE+Lab+0,100,100 https://www.wolframalpha.com/input/?i=CIE+Lab+50,-50,-50 And from https://www.easyrgb.com/en/convert.php#inputFORM:
Perhaps this warrants a note in the README? |
Actually I was just investigating this exact same issue. In the library I'm working on, I'm following these instructions to convert Lab to RGB, and I'm getting slightly different values than from d3-color, but they seem to match Wolfram Alpha's. May be related to the choice of iluminant? D3 takes note of D65, but the W3C steps include a conversion from D50 (Lab) to D65 (sRGB) white point. To make matters even more confusing, the W3C spec (and the ICC.1:2004) use Xn = 0.9642, Yn = 1.0000, and Zn = 0.8249 for D50, while Wikipedia says they're Xn = 0.966797, Yn = 1.0000, and Zn = 0.825188 (citation needed?)] 😅 |
Empirically, doing sRGB to Lab / LCh (now using the D50 standard illuminant as a reference white), gives me the following bounds:
|
Channel | Range | Description |
---|---|---|
l |
[0, 100] |
Lightness |
a |
[-79.2872, 93.55] |
Green–red component |
b |
[-112.0294, 93.3884] |
Blue–yellow component |
lch
Channel | Range | Description |
---|---|---|
l |
[0, 100] |
Lightness |
c |
[0, 131.207] |
Chroma |
h |
[0, 360] |
Hue |
Most importantly: Thanks for your work on d3! 🎉 , ❤️ and 🥇!
I was trying to use
d3-color
for sRGB to CIE-L*a*b* conversions today:You expect L*a*b* values to be
[[0-100], [-100,100], [-100,100]]
, correct? What colorspace are these RGB values in? I was expecting[0,255]
.Am I using the API incorrectly?
(This is with node v8.9.0, fwiw)
The text was updated successfully, but these errors were encountered: