Kamran Jabbar
Kamran Jabbar

Reputation: 878

LAB value to image conversion

I have CSV with LAB value, I want to convert that LAB value to image for example from this website https://www.nixsensor.com/free-color-converter/ when I enter LAB value it shows colored image. How can do this with Python? Should I do LAB to RBG if yes how? and then from RGB to image? TIA enter image description here

Upvotes: 2

Views: 478

Answers (1)

Kel Solaar
Kel Solaar

Reputation: 4070

There are many Python packages performing this type of conversion, it is two lines with Colour that I maintain:

>>> import colour
>>> colour.XYZ_to_sRGB(colour.Lab_to_XYZ([52, 25, 50])) * 255
array([ 181.13594388,  105.41357976,   34.35930998])

Alternatively, with the Automatic Colour Conversion Graph and the CIE Lab values normalised:

>>> import colour
>>> colour.convert([52. / 100., 25. / 100., 50. / 100.], 'CIE Lab', 'Output-Referred RGB')  * 255
array([ 181.13594388,  105.41357976,   34.35930998])

The numerical differences are likely caused by the different illuminants used, Colour uses D65 by default.

Upvotes: 2

Related Questions