15,749,352 members
See more:
I'm working with OpenGL and C. I have RGB input in openGL and need to do computation in CIE XYZ color space. So I do conversion following this color conversion rules.
C++
```|X|   |0.412453 0.357580 0.180423 | |R|
|Y| = |0.212671 0.715160 0.072169 |.|G|
|Z|   |0.019334 0.119193 0.950227 | |B|```

Now, that I have the value in 3D space XYZ colorspace, I want to convert it into 2D space CIE chromaticity diagram. So I normalized the XYZ into xy plane.
C++
```x = X/(X+Y+Z)
y = Y/(X+Y+Z) ```

Is there anyway I can draw this CIE chromaticity diagram and plot the points using openGL ? I can't find any information related to it.

What I have tried:

Do RGB-CIE XYZ conversion and convert it into 2D plane of xy chromaticity diagram.
Posted
Updated 29-Jan-19 9:58am
v2
[no name] 29-Jan-19 15:22pm
So you know how to calculate XYZ from sRGB and you know how to calculate xy from XYZ. Is your final problem to show these "xy" values in a "xy" plane by OpenGL?

Btw: This for the math, but I assume you know this allready:www.brucelindbloom[^]

## Solution 2

I'm not sure what your problem exactly is,
a.) OpenGL?
b.) Calculations?

From your question I see you recognized how to come from 3D- XYZ Space to xy(Y) space.

Anyway:
Here you will find a set of formulas from convert from Spectrum to XYZ on from there to xyY, sRGB, etc. and vice versa (of course excl. 3D back to spectrum):
www.brucelindbloom.com[^]

Here a good article on CP with also a lot of background info:
Color Topics for Programmers[^]

I hope it helps.

Explaining how to calculate(show) the "horse Shoe" in the xy- plane is too much to explain it here ;)

v3
lock&_lock 29-Jan-19 16:16pm
Hi, thanks. I was able to convert already. I want to draw confusion line, like this

I know exactly the value of copunctal point (where all the lines converge), but I'm still confused how to specify the value since the copunctal point is not in xy coordinate but in wavelength value. Is there any way I can render this in opengl and C ? I want to see if my calculation was correct or not, I thought it'd make the best sense if I could just draw the graph. As of now, I'll read your recommendation, thanks. Let me know if you have further advice.
[no name] 29-Jan-19 16:22pm
Youe are welcome. Can you explain me what exactly you understand under "confusion line"? The term "confusion line" confuses me a little bit at the moment ;)

And one thing more: I think for a first 2D graphics I would use something more easy like OpenGL unless you are already familiar with OpenGL.
[no name] 29-Jan-19 16:25pm
Or is it maybe "only" the question how to find e.g. 440nm in the xy -plane (which is not trivial but possible to answer)?
lock&_lock 29-Jan-19 16:38pm
hi, 400nm would be 0.16 and 0.009. What I wanted was to draw it with openGL and C, I want to know if it's correct or not. As I said in the previous comment, I found tutorial in phyton but I'm not familiar with phyton. It'd be lovely if I can do it using C. Also unfortunately I've been using glut and OpenGL, not modernOpenGL. I wonder if it's possible. thanks again.
[no name] 29-Jan-19 16:55pm
Quote "400nm would be 0.16 and 0.009":
Are you using 2° or 10° observer?

## Solution 1

lock&_lock 28-Jan-19 10:14am
Hi thanks, actually I did read before i posted here. Chances are either it's not the easiest thing for me to grasp, or it's not there. It doesn't say anything related to the spectrum on the line nor the conversion to xy plane. So yeah, not the most helpful answer for me.
Richard MacCutchan 28-Jan-19 11:59am
Well this is not a programming question that we can answer for you. You will need to do the research for yourself to find the simplest algorithm to use.
[no name] 29-Jan-19 15:25pm
This is programming question. OP does know how to calculate the values, but seems not able to show them in an OpenGL graphics...
Richard MacCutchan 29-Jan-19 15:33pm
No, he is trying to figure out how to convert one set of values (3D) to another set (2D). Until he knows the formula for that conversion there is not much that can be done in programming terms.
[no name] 29-Jan-19 15:37pm
This 3D to 2D he explained exactly in the right way:
x = X/(X+Y+Z)
y = Y/(X+Y+Z)
It is colorimetrics (my daily job) and he recognizes this part well ;)