Calculating the Y value in xy diagram and how to plot color gamuts in 3D

69 Views Asked by At

I am trying to plot 3D gamut for srgb or even xyY diagram. But i dont know how to generate the mesh for it. I am trying to achieve something like this in plotly: srgb gamut in 3D

I dont know how to calculate the Y values in the inner points of the spectrum locus. I also want to somehow create a mesh of CIE xyY hull, but i dont know how exactly.

Hello everyone, currently i have problem visualising color gamut in 3D space. Here is how I am progressing.

I have x_bar,y_bar,z_bar data from the cie 1931 XYZ 2-degree observer.

I know i can plot this data in 3D, by using the corresponding x_bar = x, y_bar = y, z_bar = z → That creates the color line shown in the graph

I can plot this data, so it is x+y+z=1, and project it onto a plane - The plane is symbolized by red triangle, and the dots on it are the projected points.

X = x/x+y+z

Y = y/x+y+z

Z = z/x+y+z

Coloring is made by this function (i am plotting the points into plotly graph):

// Function to convert XYZ color to RGB color
      function xyzToRgb(x, y, z) {
        const r = x * 3.2406 + y * -1.5372 + z * -0.4986;
        const g = x * -0.9689 + y * 1.8758 + z * 0.0415;
        const b = x * 0.0557 + y * -0.204 + z * 1.057;

        // Convert the RGB values to the range 0-1
        const normalize = (v) =>
          v <= 0.0031308 ? v * 12.92 : 1.055 * Math.pow(v, 1 / 2.4) - 0.055;
        return [normalize(r), normalize(g), normalize(b)].map((v) =>
          Math.round(v * 255)
        );
      }

My projected points in the 3D space

To plot it into 2D, i can make small change, that Z = 0, so i look at it from the top down, and i get the spectrum locus

My spectrum locus

Now, my goal is to plot different gamuts in the 3D space, i am using plotly, but essentially i am trying to somehow generate data, i can use to plot it into my 3D graph

I know color cannot be correctly represented, because of the whole concept of CIE diagram, but i have seen pictures like this:

xyY diagram

srgb color gamut in 3D Source

I dont know how to calculate the “inner” values in the spectrum locus and their Y value ( i only have x,y values), or even their correct color for that matter. I have spectrum locus, and i also know for example the position of primaries, but i dont know how to correctly calculate the Y values in 3D space to get mesh like in the video or in the picture. Maybe i am missing something obvious, so i am here asking for any advice.

PS: There is a mathlab function : plotChromaticity("ColorSpace","uv","View",3,"BrightnessThreshold",0), but it is in some background api that is not public, but for example that also plots the color in some way Mathlab function output

Thank you in advance for any help

0

There are 0 best solutions below