Skip to content

Implement OKLAB color space conversions#116

Merged
Qix- merged 8 commits intoQix-:masterfrom
Neraste:feature/oklab
May 13, 2025
Merged

Implement OKLAB color space conversions#116
Qix- merged 8 commits intoQix-:masterfrom
Neraste:feature/oklab

Conversation

@Neraste
Copy link
Copy Markdown
Contributor

@Neraste Neraste commented May 6, 2025

This PR aims to implement the conversions to/from OKLAB and OKLCH color spaces, from the post of Ottosson1. Inverse of the $M_1$ and $M_2$ matrices of the XYZ - OKLAB conversion were computed with Python's numpy.linalg.inv.

I’m not sure about the scale of OKLAB and OKLCH. Components are usually in the $[0, 1]$ range, and I multiplied most of them by 100, because the final functions convert.xxx.yyy are supposed to output integers. This value is usually not reached however (for OKLAB’s $a$, and $b$, and OKLCH’s $c$, see the updated readme for bounds).

Progress:

  • XYZ - OKLAB;
  • RGB - OKLAB;
  • OKLAB - OKLCH;
  • Factorization of sRGB non-linear transformation and its inverse;
  • Add/complete bounds in documentation.

Fixes #111.

Footnotes

  1. Ottosson, Björn (23 Dec 2020), "A perceptual color space for image processing", visited on 2025-05-07.

@Neraste Neraste marked this pull request as ready for review May 9, 2025 00:57
@Qix- Qix- merged commit 8246bc4 into Qix-:master May 13, 2025
4 checks passed
@Qix-
Copy link
Copy Markdown
Owner

Qix- commented May 13, 2025

Thanks, this is incredible work! Released as 3.1.0. Really appreciate the PR!

@Neraste Neraste deleted the feature/oklab branch May 17, 2025 15:49
@Neraste
Copy link
Copy Markdown
Contributor Author

Neraste commented May 17, 2025

You're welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for oklab colors?

2 participants