Skip to content

[css-color-4] Evaluate static gamut mapping algorithms for oklab/oklch spaces #10579

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

Open
ccameron-chromium opened this issue Jul 16, 2024 · 4 comments
Labels
css-color-4 Current Work

Comments

@ccameron-chromium
Copy link
Contributor

ccameron-chromium commented Jul 16, 2024

Separating the action item "ccameron: review gamut mapping algorithms" from here into a new issue. Tagging in @foolip @LeaVerou @svgeesus for the more limited discussion here (please feel free to include anyone else).

From the linked resolution in the issue, these algorithms are not to be applied to the various RGB spaces. I'd like to scope my comments to just "gamut mapping to apply to oklab/oklch" spaces, since I feel a bit differently about XYZ and Lab spaces (I would want XYZ and Lab to follow RGB, because they are the canonical profile connection spaces used in ICC based color matching, and don't want to mix this discussion with those issues).

The properties that I'd like for the algorithm to apply to just-oklab/oklch are much looser. An iterative algorithm with quadratic convergence is quite fine.

There were lots of algorithms listed in issue 9449, so I'd like to collect a reduced list of candidates here to discuss.

To provide an extremely short list:

  • Projecting in oklab [edit, fixed typo] to the Rec2020 gamut boundary along constant L
    • This is what's proposed in the spec (modulo termination conditions and iteration method)
    • We can write out the details for an exact solution that quadraticly converges (it's a bit of work, but I can do it if desired)
    • An exact solution for the exact Rec2020 boundary may not be desirable
      • There is some concave nastiness around the blue corner of the gamut that it would be nice to avoid.
      • There is also chrome reduction as discussed in the spec
      • Creating a "nicer-shaped" surface very close to the Rec2020 gamut might be a good solution here
  • Projecting in Rec2020 YUV along constant Y
    • This is extremely fast and probably quite good.
@svgeesus
Copy link
Contributor

Thanks for starting this.

  • Projecting in Lab to the Rec2020 gamut boundary along constant L

Why Lab and not Oklab, given the hue curvature of Lab (especially in blues, but also in orange to a lesser extent).

I agree that mapping to a smoothed gamut boundary may well be better.

  • Projecting in Rec2020 YUV along constant Y

That is video luma, right? Where Y is computed without bothering to undo gamma-encoding first?

@svgeesus svgeesus added the css-color-4 Current Work label Jul 16, 2024
@ccameron-chromium
Copy link
Contributor Author

Thanks for starting this.

  • Projecting in Lab to the Rec2020 gamut boundary along constant L

Why Lab and not Oklab, given the hue curvature of Lab (especially in blues, but also in orange to a lesser extent).

Sorry, that was a typo. I fixed up the original comment.

I agree that mapping to a smoothed gamut boundary may well be better.

  • Projecting in Rec2020 YUV along constant Y

That is video luma, right? Where Y is computed without bothering to undo gamma-encoding first?

In the experiments that I did (which was not very exhaustive), I was doing this in linear space, but that was just because it was easier to plug into the pipeline at that stage.

Another option was to find the nearest point in the L2 sense in YUV space (either linear or gamma encoded). I haven't investigated that thoroughly.

@svgeesus
Copy link
Contributor

Sorry, that was a typo. I fixed up the original comment.

Ah okay, makes sense.

I was doing this in linear space

That makes the calculated lightness accurate, so good. It doesn't make the UV plane perceptually uniform, of course.

@svgeesus
Copy link
Contributor

There is some concave nastiness around the blue corner of the gamut that it would be nice to avoid.

This is clearly seen in CSS Color 4, Figure 2.

sRGB-DisplayP3-rec2020-in-Oklab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-color-4 Current Work
Projects
None yet
Development

No branches or pull requests

2 participants