-
Hello, I'm trying to transform spectral intensities into RGB colors.
But in the
And even worse, the function gives me negative values for some input data. Thus i can't plot the color because of invalid values. eg:
for other datapoints it works fine:
With And apologies if I'm doing something completely wrong. I'm not that familiar with the field and use the colour-library only for a specific task :) Regards Edit: 0.3.7 is my version |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Hi @Lensz, Negative values are not unexpected and bad, they are actually very desirable! Let me explain: a given RGB colourspace gamut may or may not be able to encode the entire visible spectrum, as a matter of fact, only a few do such as ACES 2065-1. When you work with 8bit or 16bit integers, what usually happens is that any colour that cannot be encoded is clipped to stay within the bounds of the RGB colourspace gamut. This effectively destroys colour information, meaning that if you wanted to go back from sRGB colourspace to CIE XYZ colourspace in your case, you wouldn't retrieve the original tristimulus values.
As an example, I plotted ColorChecker N Ohta SPDs on the 1931 chromaticity diagram, notice how the cyan colour is out of sRGB gamut:
This is actually a warning from Numpy and can safely be ignored in that case, the sRGB OECF power function receive a value that makes it unhappy.
That's where you need to choose how you want to handle those colours, they cannot be properly represented and plotted by sRGB colourspace, thus you have to alter them if you want to do so (and likely explain that they were altered). #191 has some quite good related references about that! |
Beta Was this translation helpful? Give feedback.
-
Technically, those negative values become non-data in the down gamut space, and as such, they can and should be clamped on the user side, I believe. |
Beta Was this translation helpful? Give feedback.
-
Yeah, in the context of OP I think they should. |
Beta Was this translation helpful? Give feedback.
-
@Lensz Hope the explanations were ok, I'll close that issue for now! |
Beta Was this translation helpful? Give feedback.
Hi @Lensz,
Negative values are not unexpected and bad, they are actually very desirable!
Let me explain: a given RGB colourspace gamut may or may not be able to encode the entire visible spectrum, as a matter of fact, only a few do such as ACES 2065-1.
When you work with 8bit or 16bit integers, what usually happens is that any colour that cannot be encoded is clipped to stay within the bounds of the RGB colourspace gamut. This effectively destroys colour information, meaning that if you wanted to go back from sRGB colourspace to CIE XYZ colourspace in your case, you wouldn't retrieve the original tristimulus values.
Colour
operates with 32bit floating point numbers, which yield negative v…