0
\$\begingroup\$

I am writing code for some color conversion work and have a confusion. My purpose for this conversion is to get the colors look reasonably correct in a typical non-professional display (PC, tablet etc) when I save as png or jpeg for example.

Here are my steps:

  • I utilize a color calibration target (ISA ColorChecker) with reference values provided by the manufacturer in Lab space with D50 white point.
  • I capture a raw image of the target and demosaic the Bayer pattern arriving at RawRGB values for each of the Calibration Target's patches (average value is taken). To calculate a color correction matrix, I want to find the (not-gamma-corrected) sRGB values starting from the Lab reference values of the Target.
  • I use the formulas in http://www.brucelindbloom.com. First step is going from Lab to XYZ I use the D50 white reference point XYZReference = 0.9642,1.0000,0.8251
  • Second step is going from XYZ to sRGB and this is where the confusion is: I arrived at the XYZ values using a D50 white point, but sRGB with D65 illuminant is the most common working color space of consumer displays. Which of the inverseM matrices shall I be using to get this right?

After the linear conversion above, I know that I must also apply the gamma-companding.

Thank you!

\$\endgroup\$
9
  • \$\begingroup\$ What makes you think the sRGB standard uses D65? Whether one uses D50 or D65 (both are sRGB compliant) should be based in the expected display conditions. If ambient light is D50, then the display should use D50. If the ambient light is D65, then the display should use D65. Photographers have traditionally used D50 because print viewing booths use D50 lighting. More recently graphic designers tend to prefer D65 because the manufacturers of many mobile devices feel their devices look brighter and sell better if they output at D65, regardless of actual viewing conditions. \$\endgroup\$
    – Michael C
    Commented Mar 30, 2021 at 9:36
  • \$\begingroup\$ Yes, I am targeting "correct colors" (as good as it gets) in a typical consumer display without additional color calibration or professional setup by the user. I updated the question to make that clearer. Thank you! \$\endgroup\$
    – bekoch
    Commented Mar 30, 2021 at 10:23
  • \$\begingroup\$ The point is that just because a device is set to output at D65 doesn't mean the viewer will "see" (i.e. perceive) correct colors when using the device in, say, a tungsten lighting environment (or a 2700K CFL lit environment). If a neutral grey signal of, say, [128,128,128] is sent to a D65 screen and viewed under much warmer lighting, the viewer will perceive a decidedly blue cast in the "neutral" grey color on the screen. \$\endgroup\$
    – Michael C
    Commented Mar 30, 2021 at 16:37
  • \$\begingroup\$ "First step is going from Lab to XYZ I use the D50 white reference point XYZReference = 0.9504,1.0000,1.0888" No, it's not. "0.9504,1.0000,1.0888" is the D65 White Point. \$\endgroup\$
    – doug
    Commented Mar 31, 2021 at 18:21
  • \$\begingroup\$ thanks @doug, I corrected the mistake. \$\endgroup\$
    – bekoch
    Commented Apr 1, 2021 at 10:46

1 Answer 1

1
\$\begingroup\$

Which of the inverseM matrices shall I be using to get this right?

Use the sRGB, Bradford adapted inversion matrix: XYZ to RGB [M]-1

3.1338561 -1.6168667 -0.4906146
-.9787684  1.9161415  0.0334540
0.0719453 -0.2289914  1.4052427

This is used because everything involved in converting from/to L*a*b* and sRGB uses D50 even though D65 is the presumed display's white point. ICC profiles use D50 as the common reference white and primary chromaticity values in the ICC profiles are already adapted to D50. So D65 can be ignored.

Using L*a*b* 50 for the middle gray Colorchecker(tm) square, Conversion to XYZ should yield: XYZ=(0.177596 0.184187 0.151993) which is about 18% of D50 white.

Multiplying the inverting matrix M, with XYZ yields the sRGB value in linear gamma: RGB=(.184,.184,.184) which is expected. Note R=G=B and they are just above 18% reflectance which is L*50.

A good crosscheck is the BruceLindbloom calculator as shown here. Note gamma has been changed from sRGB's standard, modified 2.2 gamma to 1.0. If you wish to save the RGB values properly the sRGB gamma should be applied. You can also use the calculator to check your gamma algorithm if you pursue doing this.

enter image description here

\$\endgroup\$
14
  • \$\begingroup\$ Yes, thank you @doug. \$\endgroup\$
    – bekoch
    Commented Apr 2, 2021 at 8:52
  • \$\begingroup\$ And to be sure I also compared the two XYZ to RGB M^{-1} matrices for D65 and D50: the D50 is numerically equivalent to first applying a XYZD50 to XYZD65 Bradford chromatic adaptation matrix, and then using the D65 M^{-1} matrix. \$\endgroup\$
    – bekoch
    Commented Apr 2, 2021 at 8:58
  • \$\begingroup\$ @bekoch Yep. The theory is that human vision adapts to D65 when the sRGB (or, for instance, Adobe RGB which is also D65 for display) image is displayed. I prefer setting the display at D50 as it's a better match to a side-by-side print illuminated with D50. Calculations are the same which makes life easier. \$\endgroup\$
    – doug
    Commented Apr 2, 2021 at 13:50
  • \$\begingroup\$ LAB is only set to D50 in v2 and v4 ICC profiles. D50 is not the CIE standard, and the CIE states that D65 is the standard and recommends D65 for most applications. THe new v5 ICCmax profiles are not dependent on D50. sRGB is defined as D65. \$\endgroup\$
    – Myndex
    Commented Sep 12, 2021 at 15:23
  • \$\begingroup\$ @Myndex. The CIE has little influence on the photographic and print industry aside from publishing a spec for D50 in a supplement back when ICC was just getting started. The new ICCmax standard certainly has a place in scientific, multi spectrum photography and 3D stuff. But it's going to be a long time before it makes a significant impact. Especially in the print industry which is no longer growing. V4 ICC profiles, which are 20 years old at this point, are still not widely used outside of a common subset with V2. And everyone uses D50 as PCS reference. No sign of that changing at this time. \$\endgroup\$
    – doug
    Commented Sep 12, 2021 at 19:16

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.