1

Iv'e found converters from xyz, and posts that talk about that posts . but couldnt find a good reference for the 'cd/m2' component of the color

1 Answers1

0

The coordinates you are giving in the question are CIE xyY (small x, small y, BIG Y), they are not CIE XYZ Tristimulus Values (BIG X, BIG Y, BIG Z). The commonality between the two is the Luminance Y. CIE xyY is a perspective projection from CIE XYZ along the Luminance Y-axis to separate Luminance and Chrominance information.

To convert from CIE xyY to HEX or RGB (sRGB) you need to follow the following path:

CIE xyY --> CIE XYZ --> RGB --> HEX

Using Colour, this transformation would be expressed as follows:

import colour
xyY = [0.615, 0.346, 5.6]
XYZ = colour.xyY_to_XYZ(xyY)
RGB = colour.XYZ_to_sRGB(XYZ, apply_cctf_encoding=False)
print(RGB)
RGB_n = colour.utilities.normalise_maximum(RGB)
print(RGB_n)
print(colour.notation.RGB_to_HEX(colour.cctf_encoding(RGB_n)))
[ 23.33310243   0.88648      0.07921734]
[ 1.          0.03799238  0.00339506]
#fe360b

or using the Automatic Colour Conversion Graph as of latest develop branch:

import colour
xyY = [0.615, 0.346, 5.6]
print(colour.convert(xyY, 'CIE xyY', 'Hexadecimal'))
.../colour/colour/utilities/verbose.py:237: ColourUsageWarning: "RGB" array contains values over 1 and will be normalised, unpredictable results may occur!
  warn(*args, **kwargs)
#fe360b

Note that because your colour is High Dynamic Range (HDR), i.e. Y = 5.6, it cannot be converted to Hexadecimal representation without a normalisation process before converting from RGB to Hexadecimal. Here the colours are normalised so that the maximum RGB value is 1 but it is also worth considering that you are using sRGB colours and divide Y by 80 which is the typical sRGB display peak luminance.

Kel Solaar
  • 3,660
  • 1
  • 23
  • 29
  • 1
    thanks for the good reference. i tried the colour library and got the same result as you did. the only problem is that xyY = [0.615, 0.346, 5.6] should result in some kind of red. and '#d9f14f' is more green. when im using the xyY calculator here http://www.easyrgb.com/en/create.php#inputFORM xyY = [0.615, 0.346, 5.6] brings #851703 which is more like a red. Kel Solaar, any ideas what brings up the difference? – zachi greenberger May 01 '20 at 11:56
  • So this one is actually interesting, the problem is because it is a high dynamic range colour, I did miss it when answering but the consequence is that the sRGB encoded value is equal to [ 3.8645932 0.94833937 0.31179851], thus red is way over 1 and thus you must normalise it in some way. There is no rule on how to normalise it though. I will amend the answer accordingly. – Kel Solaar May 01 '20 at 21:28
  • Thanks to you! Because of your question, we implemented better support for that type of conversion: https://github.com/colour-science/colour/issues/584#issuecomment-623042539 – Kel Solaar May 22 '20 at 20:56