Re: [csswg-drafts] [css-color-4] Define gamut mapping (#5191)

@jrus wrote:

> One more thing. Since binary search does not always return correct results for mapping into RGB gamut, one possible alternative to specify:

> Take your curve (either a line pointed toward gray along constant hue/lightness or some other curve that eventually intersects the gamut boundary) and intersect it with all of the six surfaces R = 0, R = 1, G = 0, G = 1, B = 0, B = 1, and then choose the most colorful intersection among those 6 which still satisfies 0≤R≤1, 0≤G≤1, 0≤B≤1, and is less colorful than the original point.

> Once this is implemented and results are correct there are various ways to skip some of the intersections or speed up the computations, but implementors should probably be left to handle the choice of specific optimizations.

Yes. Finding that intersection analytically, or finding a fast approximation to the geometric intersection, is the approach examines (and well explained) in [Studying Gamut Clipping ](http://simonstechblog.blogspot.com/2021/05/studying-gamut-clipping.html).

And I agree about optimizations. I intend to describe what must be done, and point out some consequences:

- for full-range RGB spaces, the white and black points are aligned
- for RGB spaces, for a constant hue plane, the lower bound is a straight line if the Lightness transfer function is a simple power law
- for RGB spaces, for a constant hue plane, the upper bound can be approximated by a straight line but that will result in visible artifacts due to the slight concavity

The choice of solving this fully analytically, or by geometric approximation, or by binary search, is then an implementer choice based on complexity, speed, and engineering effort.

-- 
GitHub Notification of comment by svgeesus
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/5191#issuecomment-944918889 using your GitHub account


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

Received on Saturday, 16 October 2021 13:55:48 UTC