Oklab color space: Difference between revisions

Content deleted Content added
mNo edit summary
m Moved conversion to/from Oklch up
Line 26:
===Color differences===
The perceptual [[color difference]] in Oklab is calculated as the [[Euclidean distance]] between the {{nowrap|(''L'', ''a'', ''b'')}} coordinates.<ref>{{cite web |last=Lilley |first=Chris |title=Better than Lab? Gamut reduction CIE Lab & OKLab |url=https://www.w3.org/Graphics/Color/Workshop/slides/talk/lilley |publisher=W3C |access-date=24 July 2024 |date=July 2021}}</ref><ref name="w3c"/>
 
===Conversion to and from Oklch===
Like CIELCh, the [[Cartesian coordinate system|Cartesian coordinates]] ''a'' and ''b'' are converted to the [[Polar coordinate system|polar coordinates]] ''C'' and ''h'' as follows:
 
<math>
\begin{align}
C &= \sqrt{a^2 + b^2} \\
h &= \operatorname{atan2}(b, a)
\end{align}
</math>
 
And the polar coordinates are converted to the Cartesian coordinates as follows:
 
<math>
\begin{align}
a &= C \cos(h) \\
b &= C \sin(h)
\end{align}
</math>
 
===Conversion from CIE XYZ===
Line 72 ⟶ 91:
\begin{bmatrix} l \\ m \\ s \end{bmatrix} &= \begin{bmatrix} \left(l'\right)^3 \\ \left(m'\right)^3 \\ \left(s'\right)^3 \end{bmatrix} \\
\begin{bmatrix} X \\ Y \\ Z \end{bmatrix} &= M_1^{-1} \times \begin{bmatrix} l' \\ m' \\ s' \end{bmatrix}
\end{align}
</math>
 
===Conversion to and from Oklch===
Like CIELCh, the [[Cartesian coordinate system|Cartesian coordinates]] ''a'' and ''b'' are converted to the [[Polar coordinate system|polar coordinates]] ''C'' and ''h'' as follows:
 
<math>
\begin{align}
C &= \sqrt{a^2 + b^2} \\
h &= \operatorname{atan2}(b, a)
\end{align}
</math>
 
And the polar coordinates are converted to the Cartesian coordinates as follows:
 
<math>
\begin{align}
a &= C \cos(h) \\
b &= C \sin(h)
\end{align}
</math>