Re: [css-houdini-drafts] [css-typed-om] Color conversion and contrast ratio (#989)

> > @atanassov wrote:
> >
> > Further, it would be great to have a function that enables contrast ratio calc given any two colors. The expectations for color contrast described by WCAG are rather detailed and lack developer ergonomics
>
> @svgeesus 
> The WCAG contrast ratio is detailed enough, for sRGB only, but lacks explanation. However it is easy to work out what is being done - the relative, D65-adapted XYZ is calculated for the two colors and the luminance (Y) is used to calculate the contrast.
> 
> Given that, it is trivial to extend to other RGB spaces (whether they use D65 or not) and to XYZ, Lab and LCH. Color.js does this, so you can ask for a contrast ratio between any pair of colors regardless of what colorspace each was originally specified in.


However, the ratio as expressed by the WCAG 2.x math is of questionable utility, as it is not relative to perception as we've discussed elsewhere. As WCAG 2.x contrast ratios do not follow visual perception, the ratio expressed is meaningless, and therefore scaling it to other spaces will carry that same meaningless presentation that does not predict the perception of contrast of a self-illuminated display. WCAG 2.x "4.5:1" is not even remotely consistent in appearance across the range of lightness on the small colorspace of an sRGB monitor, and I should think that scaling to much larger spaces will only exacerbate this problem.

A similar problem exists with Weber, Mod-Weber, and Michelson, as they are all set to predict contrast at threshold for the JND, but become increasingly inaccurate at suprathreshold levels. Suprathreshold contrast prediction is what is needed to give designers useful guidance for readability/discernibility.

At the moment, the implementation of contrast prediction for Silver/WCAG 3.0 is the APCA (derived from SAPC) which is a suprathreshold perceptual contrast appearance model. Presently it is aligned with the sRGB transfer curve, using a standardized observer with ambient luminance at 20% of display max white. 

It is sensitive to ambient levels, spatial frequency, and other factors — and for HDR there is the question of where "page white" and "peak white" are mapped (not to mention the different HDR TRC types). Fitting to different transfer curves or gamma, and different expected environments, and as well considering certain adaptive technologies, adds significant complexity as far as selecting the various constants & exponents.

From an accessibility perspective, the coordinates for the primaries of a given colorspace will have an effect on useful choices of constants for improving accessibility with certain impairments. 

This leads us to question if we need considerations of things like the H-K effect on perceived contrast — though for readable content, we are mostly interested in font contrast against a background that helps get stimuli to the Visual Word Form Area (VFWA), a pre-lexical processing of whole words and letter pairs, needed for best readability and reading speed.

Current research indicates that this processing path relies on the luminance component, and not chroma. Nevertheless, hue & chroma have implications for various impairments and other visual issues such as chromatic aberration, glare, scatter, and CVD. As such even a perceptual contrast based only on perceived lightness (derived from calculated luminance) presents challenges for accessibility with tristimulus color models.

### TLDR

All of this is a long way to say that these (SAPC/APCA/RLAB/CAMxx/etc) methods for contrast appearance prediction are certainly scalable to different spaces, but not necessarily trivial if the goal is a perceptual uniformity across the various colorspaces. 

If we assert that perceptual uniformity is desired for the contrast metric to be useful, then the extra effort for such scaling/mapping is warranted. There are some enhancements I have not made public yet that may become helpful for some of these more complex issues, but still under evaluation.

Andy


-- 
GitHub Notification of comment by Myndex
Please view or discuss this issue at https://github.com/w3c/css-houdini-drafts/issues/989#issuecomment-844025007 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 19 May 2021 11:48:22 UTC