Skip to content
Advertisement

RGB to XYZ and LAB colours conversion

I’m having problems converting colours from RGB to LAB space It should be straight forward using the formulas from here, only I’m getting back the wrong values

  • RGB = 56,79,132

  • X = 8.592

  • Y = 8.099
  • Z = 22.940

and CIE-L*ab as

  • L* 34.188
  • a* 8.072
  • b* -32.478

This is my code; but I can’t see where I’m going wrong. It maybe due to floating points like this fella before me. Thank you.

JavaScript

Advertisement

Answer

I’m pretty sure ^ is bitwise xor in javascript not a power operator. I think Math.pow is what you are looking for.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement