0
$\begingroup$

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:

...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!

$\endgroup$

1 Answer 1

1
$\begingroup$
  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.

$\endgroup$
2
  • $\begingroup$ 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! $\endgroup$ Jan 21 at 15:18
  • $\begingroup$ 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 $\endgroup$ Jan 21 at 15:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.