0

I need to obtain the CIE x and y coordinates from the chromaticity diagram. I tried the following: take an RGB point, convert to sRGB, plot it. Separately convert the RGB to xyY, and compare the results.

import numpy as np
from colour.plotting import *
import colour

rgb = np.array([100,50,200])
RGB = colour.models.eotf_inverse_sRGB(rgb / 255)
plot_RGB_chromaticities_in_chromaticity_diagram_CIE1931(RGB)

and get the following:enter image description here

So the coordinates that I am looking for are around [0.3, 0.26]. As far as I understand to get them I need to transform RGB to XYZ, and take XY coordinates. I found the following solution:

illuminant_RGB = np.array([0.31270, 0.32900])
illuminant_XYZ = np.array([0.34570, 0.35850])
chromatic_adaptation_transform = 'Bradford'
RGB_to_XYZ_matrix = np.array([[0.41240000, 0.35760000, 0.18050000],
                              [0.21260000, 0.71520000, 0.07220000],
                              [0.01930000, 0.11920000, 0.95050000]])
result = colour.RGB_to_XYZ(rgb/255., illuminant_RGB, illuminant_XYZ, RGB_to_XYZ_matrix, chromatic_adaptation_transform) 
colour.XYZ_to_xyY(result)

However that produces [ 0.29439225, 0.22595116, 0.27536142], which is not correct.

Sanya Pushkar
  • 180
  • 1
  • 16
  • 1
    Note: CIE xyY is not CIE XYZ (so x,y,z are not X, Y, Z). And you should be careful about the meaning of x, y chromacities. The above figure (which it is obviously wrong because it represent colour that cannot be displayed in our screen) is always a cut/projection of real 3-D figures. And there are few standard way to make such cut. You have the max Y cut (so you see yellow. Often you have just a mix, so you will not see yellow (but orange) [which have same chromacity]). So x = X/(X+Y+Z), y = Y / (X + Y + Z) – Giacomo Catenazzi Jan 27 '22 at 07:34
  • Thank you! I corrected the question, to also reflect the switch to sRGB for plotting. Still it doesn't add up.. – Sanya Pushkar Jan 27 '22 at 16:48

0 Answers0