Comments (5)
Empirically, doing sRGB to Lab / LCh (now using the D50 standard illuminant as a reference white), gives me the following bounds:
lab
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 |
from d3-color.
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?)]
😅
from d3-color.
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. color.displayable()
will let you know when that's the case. (What you can do is clamp the R/G/B channels to [0, 255]
)
This color picker can give you a sense of when the colors get clipped.
from d3-color.
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.
from d3-color.
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
24-bit RGB | red 105 | green 0 | blue 0
https://www.wolframalpha.com/input/?i=CIE+Lab+50,-50,-50
24-bit RGB | red 0 | green 142 | blue 204
And from https://www.easyrgb.com/en/convert.php#inputFORM:
CIE-L*ab (D65/2°) = 50 -50 -50
sRGB 0-255 = -868.512 143.165 203.450 D65/2°
Perhaps this warrants a note in the README?
from d3-color.
Related Issues (20)
- d3.rgb doesn't parse HSL hues with `deg` units HOT 1
- Changing color.s changes luminosity and color.l saturation.
- Security vulnerability fix for d3-color required in version 2.x HOT 7
- Security vulnerability fix for d3-color nice-to-have in version 1.x HOT 4
- Unexpected token 'export' while update from 2.x.x to 3.x.x HOT 2
- Why d3 uses illuminant D50 instead of D65? HOT 1
- d3.hsl doesnt seem to work with grey scale values HOT 2
- Alpha value of 0 breaks rgb HOT 1
- Add formatHex8() to include opacity HOT 7
- Brightening black in RGB HOT 3
- bug: hue is NaN when convert hsl HOT 2
- Unexpected conversion to HSL
- Incorrect conversion from HCL / LCH to hex or rgb HOT 2
- oklab / oklch? HOT 8
- More exports. HOT 9
- Doesn't work - color is not defined HOT 1
- Does the Common JS version of the module work? HOT 1
- Supporting CSS color level 4 HOT 3
- Avoid catastrophic backtracking when parsing HOT 11
- formatHex with alpha channel HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from d3-color.