I am facing some problems with plotting RGB values into a chromaticity diagram:
I have some different RGB values and I want to plot them into a chromaticity diagram to make them visual. I want to make them visual because of I have to presentate them and I want that everyone can see the colordifference.
With the colour package in Python I can make the chromaticity diagram and I can plot 1 RGB value. When I add some more RGB value I get an error.
This is my code:
import numpy as np
from colour.plotting import *
RGB = np.array([79, 2, 45], [87, 12, 67])
plot_RGB_chromaticities_in_chromaticity_diagram_CIE1931(
RGB,)
And I receive this error:
Traceback (most recent call last): File "C:\Users\User\PycharmProjects\pythonProject4\Overige\Cie.py", line 8, in RGB = np.array([79, 2, 45], [87, 12, 67]) TypeError: Field elements must be 2- or 3-tuples, got '87
In this diagram I want to plot my RGB values:
In total I would like to plot arround 20 RGB values into this diagram.
Can someone help me to fix this or is there a better/easier way to do this?
Thanks!
While @giacomo-catenazzi answer is correct, there is some more subtlety going on here.
The expectation for the colour.plotting.plot_RGB_chromaticities_in_chromaticity_diagram_CIE1931
definition input is to be linear floating point RGB data, encoded using sRGB colourspace as a default.
Here, your RGB values are integer and could be 8-bit non-linearly encoded sRGB values, thus you might need to convert them to floating-point representation and decode them:
import colour
import numpy as np
from colour.plotting import *
RGB = colour.models.eotf_inverse_sRGB(np.array([[79, 2, 45], [87, 12, 67]]) / 255)
plot_RGB_chromaticities_in_chromaticity_diagram_CIE1931(RGB)
Basically, you need to know how they have been encoded so that internally, the definition does the correct maths to present them.