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

Does the HCT color model support wide gamut (colors beyond sRGB)? #131

Open
FluorescentHallucinogen opened this issue Dec 3, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@FluorescentHallucinogen
Copy link

I've found that material-color-utilities uses sRGB color space under the hood in many places in the code, e.g. in the image quantizer:

const argb = argbFromRgb(r, g, b);
pixels.push(argb);
}
// Convert Pixels to Material Colors
const result = QuantizerCelebi.quantize(pixels, 128);

Also

const context = canvas.getContext('2d');

instead of:

const context = canvas.getContext('2d', { colorSpace: 'display-p3' });

This means that e.g. if we fill the whole image with any color from the P3 color space that doesn't exist in sRGB color space, then quantize function will not return the same identical color as the dominant color of that image.

E.g. OKLCH color model supports not only sRGB color space, but also wide-gamut color spaces (P3, Rec2020 and beyond). See https://evilmartians.com/chronicles/oklch-in-css-why-quit-rgb-hsl.

Technically, OKLCH can represent any color visible to the human eye.

You can play around with https://oklch.com to construct colors that can't be displayed on displays that doesn't support P3/Rec2020 or on any existing device.

It's not clear from the https://material.io/blog/science-of-color-design blog post if HCT color model supports wide gamut (colors beyond sRGB) or not?

@FluorescentHallucinogen
Copy link
Author

Adding @jpohhhh, who works on color at Google, and who definitely knows the answer. 😉

@facelessuser
Copy link

The HCT color model is just the CAM16 color model paired with CIE Lab lightness. It can support P3 and Rec. 2020 because CAM16 and CIE Lab can support these gamuts. It should be noted that color spaces that extend outside of the visible spectrum (ProPhoto RGB) can stress the CAM16 algorithm as the geometry of the space in the blue region starts to wrap around into itself, so HCT would have similar limitations, but most reasonable gamuts should be supported. OkLCh also can experience weird distortions in its geometry when extended past the visible spectrum as well.

I've implemented HCT as a normal color space, and as you can see it can be rendered within the Rec. 2020 gamut just fine. I think this library just doesn't support gamuts beyond sRGB currently, but there is nothing limiting the potential to extend it further.

hct

@pennzht pennzht added the enhancement New feature or request label Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants