<ol>
<li>convert sRGB to RGB by first removing gamma (colors must be in linear  color space for the conversions to be accurate) The Fujiwaratko site is confusing since it lists sRGB in its table but the Lindbloom site correctly lists that the color must be in linear space to get a valid transform.</li>
<li>convert from RGB to XYZ. Be careful with the illuminate here. Lab often uses D50 for the illuminate. So...</li>
<li>if the illuminate needs to be converted from D65 to D50 use one of the conversion matrices needed for this. The Lindbloom site gives a nice overview and the steps needed here: <a href="http://www.brucelindbloom.com/Eqn_ChromAdapt.html" rel="nofollow noreferrer">http://www.brucelindbloom.com/Eqn_ChromAdapt.html</a></li>
<li>Finally convert from XYZ to LaB. This conversion is non-linear so a simple matrix can't be used. The tables on the Fujiwaratko site on the XYZ to Lab page give the combined matrix that includes D65 to D50 conversion. I recommend just breaking it into multiple steps until the code is producing the expected results. This gives more opportunities to check that the conversion has been done correctly.</li>
</ol>
<p>Unfortunately there is no simple function to do this conversion. Even the online converters will give different results depending on the setup. The Lindbloom site has a conversion tool that allows for the most variables to be set which can be helpful in getting accurate conversions but can also be confusing to use.</p>

CC BY-SA 4.0
2024-01-21T15:18:58.070Z
I finally got it right!! Thank you so much! Ended up using straight up D65 on Lab - I also got the idea D50 was the most used on Lab idk where but wiki says its only with the printing industry, with most of the other industries using D65. But do you think it's wrong? Thanks again!
Pedro Ribeiro
CC BY-SA 4.0
2024-01-21T15:24:43.377Z
also, the Lindbloom calculator doesn't seem to work with me? nothing happens when I write the color value on each slot. i'm on PC, tried on Chrome and Edge. so I'm using easyrgb.com instead
Pedro Ribeiro
CC BY-SA 4.0
2024-01-21T14:11:23.150Z
2024-01-21T14:11:23.150Z
pmw1234
<p>I've been struggling to implement the correct steps (matrices, white-points, etc) to convert some sRGB (RGB) values (already in 0-1 range) to Lab/CIELAB color space.</p>
<p>I've tried following guides on multiple sites like:</p>
<ul>
<li><a href="https://fujiwaratko.sakura.ne.jp/infosci/colorspace/colorspace2_e.html" rel="nofollow noreferrer">www.fujiwaratko.sakura.ne.jp - RGB to XYZ</a></li>
<li><a href="https://fujiwaratko.sakura.ne.jp/infosci/colorspace/colorspace3_e.html" rel="nofollow noreferrer">www.fujiwaratko.sakura.ne.jp - XYZ to Lab</a></li>
<li><a href="http://www.brucelindbloom.com/index.html?Eqn_RGB_to_XYZ.html" rel="nofollow noreferrer">www.brucelindbloom.com</a></li>
</ul>
<p>...but the guides show multiple ways of doing it depending on various factors and are divided by multiple pages, which seem to re-reference steps sometimes, and basically the values I end up with are not correct so I must be doing it wrong (color math is also new to me).</p>
<p>I'm using a program to do the math so the mistake isn't in me doing the calculations per se wrong.</p>
<p>Also, the whole equations behind the values of the matrices is not really necessary, to be clear. I'm just trying to find a one-piece guide with the formulas to transform sRGB into Lab.</p>
<p>I've been struggling with this for days, If anyone would take their time to help me, I would really appreciate it!</p>

<mathematics><matrix><colorspace><conversion>
What are the exact math steps to convert sRGB (D65) to Lab (D50) colorspace?
Pedro Ribeiro
# What are the exact math steps to convert sRGB (D65) to Lab (D50) colorspace?

(Asked by: username_0 on 2024-01-20)

I've been struggling to implement the correct steps (matrices, white-points, etc) to convert some sRGB (RGB) values (already in 0-1 range) to Lab/CIELAB color space.

I've tried following guides on multiple sites like:

* [www.fujiwaratko.sakura.ne.jp - RGB to XYZ](https://fujiwaratko.sakura.ne.jp/infosci/colorspace/colorspace2_e.html)
* [www.fujiwaratko.sakura.ne.jp - XYZ to Lab](https://fujiwaratko.sakura.ne.jp/infosci/colorspace/colorspace3_e.html)
* [www.brucelindbloom.com](http://www.brucelindbloom.com/index.html?Eqn_RGB_to_XYZ.html)

...but the guides show multiple ways of doing it depending on various factors and are divided by multiple pages, which seem to re-reference steps sometimes, and basically the values I end up with are not correct so I must be doing it wrong (color math is also new to me).

I'm using a program to do the math so the mistake isn't in me doing the calculations per se wrong.

Also, the whole equations behind the values of the matrices is not really necessary, to be clear. I'm just trying to find a one-piece guide with the formulas to transform sRGB into Lab.

I've been struggling with this for days, If anyone would take their time to help me, I would really appreciate it!

**Tags:** mathematics, matrix, colorspace, conversion


---

## 1 answers

### Answer by username_1 on 2024-01-21. Score: 1 | Accepted answer

1. convert sRGB to RGB by first removing gamma (colors must be in linear color space for the conversions to be accurate) The Fujiwaratko site is confusing since it lists sRGB in its table but the Lindbloom site correctly lists that the color must be in linear space to get a valid transform.
2. convert from RGB to XYZ. Be careful with the illuminate here. Lab often uses D50 for the illuminate. So...
3. if the illuminate needs to be converted from D65 to D50 use one of the conversion matrices needed for this. The Lindbloom site gives a nice overview and the steps needed here: <http://www.brucelindbloom.com/Eqn_ChromAdapt.html>
4. Finally convert from XYZ to LaB. This conversion is non-linear so a simple matrix can't be used. The tables on the Fujiwaratko site on the XYZ to Lab page give the combined matrix that includes D65 to D50 conversion. I recommend just breaking it into multiple steps until the code is producing the expected results. This gives more opportunities to check that the conversion has been done correctly.

Unfortunately there is no simple function to do this conversion. Even the online converters will give different results depending on the setup. The Lindbloom site has a conversion tool that allows for the most variables to be set which can be helpful in getting accurate conversions but can also be confusing to use.

> **Comments:**
> **username_0**: I finally got it right!! Thank you so much! Ended up using straight up D65 on Lab - I also got the idea D50 was the most used on Lab idk where but wiki says its only with the printing industry, with most of the other industries using D65. But do you think it's wrong? Thanks again!  
> **username_0**: also, the Lindbloom calculator doesn't seem to work with me? nothing happens when I write the color value on each slot. i'm on PC, tried on Chrome and Edge. so I'm using easyrgb.com instead  

---

