Skip to main content
scotwllm
Inspiring
December 6, 2024
Question

How does Photoshop calculate Lab values?

  • December 6, 2024
  • 5 replies
  • 4442 views

In the Color Picker tool, Photoshop presents the Lab values of colors if you type in the RGB or HSB values. 

I doubt Adobe goes to one of the color conversion websites to get the Lab values. Does anybody know the formula they use to calculate it?

 

Scott

This topic has been closed for replies.

5 replies

Conrad_C
Community Expert
Community Expert
December 8, 2024

It might help to understand the quote below from the book “Real World Photoshop CS3” which was published in 2008. It also appeared in the book’s earlier editions by the late Bruce Fraser, as well as his book “Real World Color Management” published in 2003. Bruce didn’t just say that out of thin air. He worked closely with the Photoshop team.

 

 

The second quote, below, is from page 33 of “The Digital Print” (2014) by Jeff Schewe, who also works closely with the Photoshop, Camera Raw, and Lightroom teams.

 

 

Anyone who studies how Photoshop color works eventually understands that: 

  • Lab is its reference color space for color conversions.
  • Any color conversions must be corrected for the specific color space of the current color mode (such as sRGB vs Adobe RGB, or FOGRA CMYK vs US SWOP CMYK). 

 

If you show an Excel spreadsheet or color conversion table that doesn’t account for color space, or doesn’t use Lab as a reference color space, that conversion table is not useful or reliable when discussing Photoshop.

davescm
Community Expert
Community Expert
December 8, 2024

I would take that one step further:

'If you show an Excel spreadsheet or color conversion table that doesn’t account for color space, or doesn’t use Lab as a reference color space, that conversion table is not useful or reliable' when discussing Photoshop.

Dave

scotwllm
scotwllmAuthor
Inspiring
December 8, 2024

I found the answer. 

davescm
Community Expert
Community Expert
December 8, 2024

Which 'flavour' of RGB or more accurately which RGB colour profile is that table converting to Lab? The calculations are different for each variation in the profile. Those variations include the the primary colours, the gamma, the white point....

 

If you want accurate numbers out you need accurate numbers in - hence the maths differs for every profile or needs to be built with more inputs to take the RGB profile detailed specification entry into those calculations.

 

Dave

 

D Fosse
Community Expert
Community Expert
December 9, 2024

Software? There's an app that works on my iPhone. I don't use the Compare or Color Match features. I use the Saved Colors function. I scan a bunch of colors, send a csv file to iCloud, and upload it into Excel. The sheet contains a lot of information I don't understand right now, but all I wanted were the hex values anyway. With the hex code, I use the hex2dec Excel function to split the code into R, G,  and B. From there, I calculate the hue, luminance, saturation, and brightness. I believe you helped me find the formulas for doing this, Stephen, so I blame everything on you. And now I have the Delta-E values. Oh! And I found some VB code that displays the color in column A (as long as R is in B, G is in C, and B is in D). I know Excel is not entirely accurate with its colors, but it shows color relationships consistently enough for what I'm doing. I created a 24 color card in Excel using the values for a Calibrite Color Checker and then created a LUT for it in 3D LUT Creator for when an extra level of precision is necessary. Having all the info in an Excel spreadsheet allows me to filter and sort and answer questions like "What's the most saturated color we have in the orange family?" Now I can answer what the closest alternative colors, or which colors can be dropped from the catalog because they're essentially duplicates.


This is going nowhere. A spectrophotometer reads and outputs Lab values, which are then recalculated into sRGB, Adobe RGB, ProPhoto or whatever you want.

 

You've been given the answer to your question several times, but for some reason you refuse to accept it. There's nothing more we can do here.

D Fosse
Community Expert
Community Expert
December 6, 2024

Stephen Marsh
Community Expert
Community Expert
December 6, 2024

Colour management.

 

Make 2 separate RGB files, one sRGB, the other ProPhoto RGB. Type in the same set of RGB values and compare the Lab readings. Type in the same Lab values and compare the RGB readings.

D Fosse
Community Expert
Community Expert
December 6, 2024

It's the other way round. All color space numbers are calculated from Lab.

 

Lab is the reference and at the base of all color management. It is one of two commonly used Profile Connection Spaces (the other is CIE XYZ).

 

A standard profile conversion goes, say, Adobe RGB > Lab > sRGB.

 

Lab numbers define a color absolutely.

scotwllm
scotwllmAuthor
Inspiring
December 8, 2024

Hi there --

 

I appreciate the time you invested to respond to my question.  However, you answered a question I didn't ask. I asked how does Photoshop calculate the numbers that appear in the color picker when a user enters RGB values. I've found formulas online that purport to do it, but they're written in code or use calculus. I took calculus around 40 years ago and have never needed to use it until now. I need to calculate the Delta-E between multiple colors, and plugging them into a website form one by one takes too much time. I'm too old to waste it on that kind of stuff, know what I mean?

D Fosse
Community Expert
Community Expert
December 8, 2024

We did answer it. The answer is color management. The Lab numbers are always there as the definition of the RGB numbers in the given RGB color space.

 

The online calculators are rubbish because they usually don't even consider color management, color spaces and icc profiles. RGB what? There is no such thing as "RGB". Numbers are undefined until associated with a specific color space.

 

Look at the screenshot I posted below. That's how given Lab numbers are represented in different color spaces.