Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

RGB to LAB conversion

Community Beginner ,
Jun 16, 2022 Jun 16, 2022

Hello. I started scripting in Photoshop a month ago so I am not completely aware of all the concepts. If I create a SolidColor object and assign RGB values to it, then get the lab colors of this object, how is the conversion performed? Basically I am trying to obtain the same LAB values in Python for an RGB color, and I want my converted L, A and B values to be the same as the ones in Photoshop. How can I perform the same conversion in Photoshop?

TOPICS
Actions and scripting , Windows
1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Jun 16, 2022 Jun 16, 2022

As the blank RGB-numbers are more or less meaningless the corresponding Lab values depend on the Color Space of the image (ususally expressed as an ICC-Profile; if the image is untagged the corresponding Working Space is used). 

So the calculation is not a »simple« arithmetic operation but depends on Color Management. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 16, 2022 Jun 16, 2022

Considering the sRGB IEC61966 color space, how would I, in Python, go about replicating the sRGB-to-LAB conversion that takes place in Photoshop?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 16, 2022 Jun 16, 2022

Technically, it's the other way round. An sRGB value is defined as a Lab value. Lab is at the heart of color management as one of two Profile Connection Spaces (the other is CIE XYZ). It's what everything refers to.

 

So any color management engine should have this built in. No idea how you would go about it in practice.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 16, 2022 Jun 16, 2022

To add to the correct info from D Fosse: All RGB color spaces (the RGB color model) are device-dependent , unlike Lab which isn't. Any RGB value has a defined by Lab, never the other way around. Lab is pretty much self-defining (that's somewhat simplistic due to how Lab white point can be altered but moot in Photoshop, that's a fixed attribute). A tagged RGB triplet can easily be converted to Lab. An untagged RGB triplet is RGB mystery meat. So you can't 'assign' RGB values without a scale, the RGB color space to go with that triplet. 

Author “Color Management for Photographers" & "Photoshop CC Color Management/pluralsight"
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 16, 2022 Jun 16, 2022

The calculation to translate RGB numbers to Lab uses the ICC profile (e.g. sRGB) and a CMM. (Color Management Module, such as Adobe ACE). I believe there are standalone CMMs.

https://helpx.adobe.com/photoshop/kb/adobe-color-management-module.html

 

different CMM's, and different rendering intents will give different results - to match Adobes conversion you need the Adobe ACE CMM I imagine. Also you'll need to decide on a rendering intent. 

 

I hope this helps
neil barstow, colourmanagement net :: adobe forum volunteer:: co-author: 'getting colour right'
google me "neil barstow colourmanagement" for lots of free articles on colour management

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 16, 2022 Jun 16, 2022

Rendering intents will of course alter the result - for instance Absolute Colorimetric will not remap the white point from sRGB (D65) to Lab (D50).

 

But that's a moot question because standard profiles like sRGB/Adobe RGB/ProPhoto don't support other rendering intents than Relative Colorimetric. The white point is always remapped. Out of gamut colors are always hard clipped without remapping near the boundary. There shouldn't be any variables.

 

And in any case sRGB IEC61966-2.1 is a defined specification. Other CMMs can't disregard that and introduce their own random values.

 

In short, this should be clearly and unambiguously defined in any color management engine. It's not Adobe specific.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 16, 2022 Jun 16, 2022
LATEST

D. Fosse, good point about working spaces and rendering intents - thanks

 

neilB

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines