# sRGB↔L*a*b*↔LChab conversions

Posted by Michał ‘mina86’ Nazarewicz on 21st of December 2022

First, rather obvious observation is that shades of grey have the same red, green and blue components. Let’s say that $$C$$ is value of those components in linear space.

First observation is that multiplying conversion matrix by column of ones produces coordinates for the reference white point. That is, $$\begin{bmatrix}X_w & Y_w & Z_w\end{bmatrix}^T = M \begin{bmatrix}1 & 1 & 1\end{bmatrix}^T$$.

First obvious observation is that for shades of grey, red, green and blue components of the colour are all the same. Let’s call that component $$k$$ and with that we can say $$r_8 = g_8 = b_8 = k_8$$ and $$R = G = B = K$$. This simplifies the sRGB→XYZ formulæ: \begin{align} \begin{bmatrix}X \\ Y \\ Z\end{bmatrix} &= M \begin{bmatrix}C \\ C \\ C\end{bmatrix} = M \begin{bmatrix}1 \\ 1 \\ 1\end{bmatrix} C = \begin{bmatrix}X_w \\ Y_w \\ Z_w\end{bmatrix} C \\[.5em] f_x &= f(X / X_w) = f(X_w C / X_w) = f(C) \\ f_y &= f(Y / Y_w) = f(Y_w C / Y_w) = f(C) \\ f_z &= f(Z / Z_w) = f(Z_w C / Z_w) = f(C) \\ &⇒ f_x = f_y = f_z\\[.5em] a^* &= 500 (f_x - f_y) = 0 \\ b^* &= 200 (f_y - f_z) = 0 \\[.5em] u_w' &= 4X_w / D_w \\ v_w' &= 9Y_w / D_w \\ D_w &= X_w + 15Y_w + 3Z_w\\[.5em] D &= X + 15Y + 3Z = X_w C + 15Y_w C + 3Z_w C = D_w C\\ u' &= 4X / D = 4X_w C / (D_w C) = 4X_w / D_w = u_w'\\ v' &= 9Y / D = 4Y_w C / (D_w C) = 9Y_w / D_w = v_w'\\[.5em] u^* &= 13 L^* (u' - u_w') = 0\\ v^* &= 13 L^* (v' - v_w') = 0\\ \end{align}