I'm trying to convert Lab colors to RGB WITHOUT gamma correction (or with gamma = 1).
I use the colormath module from within Blender. https://python-colormath.readthedocs.io/en/latest/#
It seems to ignore my gamma setting. The conversion is right otherwise (I verified it step by step in Excel using Bruce Lindblooms wisdom http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
Essentially, I need to skip gamma companding, or set the gamma factor to 1.
colormath always returns gamma corrected values, no matter how I set rgb_gamma. I suspect that I'm using the rgb_gamma function wrong, but I can't figure out how to do it right.
from colormath import color_objects
from colormath import color_constants
from colormath import density
from colormath.color_conversions import convert_color
from colormath.color_objects import (
LabColor,
sRGBColor,
XYZColor,
)
#77,82 17,56 7,85 input
#0,800 0,456 0,449 sRGB no gamma, calculated in Excel
#0,906 0,706 0,700 gamma corr.
BRlab=LabColor(77.82,17.56,7.85, observer='2', illuminant = 'c')
print(BRlab)
BRxyz=convert_color(BRlab, XYZColor, target_illuminant = 'c')
print(BRxyz)
BRxyz.set_illuminant('c')
BRxyz.set_observer('2')
BRxyz.apply_adaptation(target_illuminant = 'd65', adaptation = 'bradford')
print(BRxyz)
BRrgb=convert_color(BRxyz, sRGBColor, target_illuminant = 'd65')
BRrgb.rgb_gamma=1.0 #this setting seems to be ignored
print("gamma = " , BRrgb.rgb_gamma)
print(BRrgb)
BRrgb.rgb_gamma=2.0 #this setting seems to be ignored, same output no matter if gamma = 1 or gamma = 2
print("gamma = ", BRrgb.rgb_gamma)
print(BRrgb)
print("\n")