Python colour AttributeError: module 'colour' has no attribute 'CCS_ILLUMINANTS'

2.1k Views Asked by At

I'm able to convert an RGB value to Lab using Colour and Numpy:

rgb = np.array([100, 80, 20]) / 255
xyz = colour.sRGB_to_XYZ(rgb)
lab = colour.XYZ_to_Lab(xyz)
print(lab) # 35, 4, 36

but when I want to use a specific white point, D50 like this example

rgb = np.array([100, 80, 20]) / 255
D50 = colour.CCS_ILLUMINANTS['CIE 1931 2 Degree Standard Observer']['D50']
xyz = colour.sRGB_to_XYZ(rgb, illuminant=D50)
print(colour.XYZ_to_Lab(xyz, illuminant=D50))

I get the error

D50 = colour.CCS_ILLUMINANTS['CIE 1931 2 Degree Standard Observer']['D50']


File "D:\Python30\lib\site-packages\colour\__init__.py", line 325, in __getattr__
    return super(colour, self).__getattr__(attribute)
  File "D:\Python30\lib\site-packages\colour\utilities\deprecation.py", line 351, in __getattr__
    return getattr(self._module, attribute)
AttributeError: module 'colour' has no attribute 'CCS_ILLUMINANTS'

What am I doing wrong?

1

There are 1 best solutions below

0
Johnny S. F. On

If you look at the colour files on Github, you can see that the correct path to CSS_ILLUMINANTS is something like this:

D50 = colour.colorimetry.datasets.CSS_ILLUMINANTS['CIE 1931 2 Degree Standard Observer']['D50']

This way, it will work