-
Hi, this are my first steps and tries in Colour - forgive me if I am doing fully wrong ;-) How can I multiply a given spectrum of a color with a "spectrum of a light source"?
As far as I see the spectral data does not match. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi @ademmler, The warning you get is probably related to a different section of the code, it is coming from the colour.models.eotf_inverse_sRGB definition. Multiplying two spectral distributions should be straightforward: You simply multiply one with the other! There is one important thing to consider though: Whether their spectral shapes are the same.
In [1]: import colour
In [2]: a = colour.sd_ones(colour.SpectralShape(400, 700, 10))
In [3]: b = colour.sd_ones(colour.SpectralShape(400, 700, 20)) * 2
In [4]: (a * b).values
Out[4]:
array([ 2., nan, 2., nan, 2., nan, 2., nan, 2., nan, 2.,
nan, 2., nan, 2., nan, 2., nan, 2., nan, 2., nan,
2., nan, 2., nan, 2., nan, 2., nan, 2.])
In [5]: (a * b[a.wavelengths]).values
Out[5]:
array([ 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2.,
2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2.,
2., 2., 2., 2., 2.])
In [6]: (a * b.copy().align(a.shape)).values
Out[6]:
array([ 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2.,
2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2.,
2., 2., 2., 2., 2.]) |
Beta Was this translation helpful? Give feedback.
-
Thx for your help! |
Beta Was this translation helpful? Give feedback.
Hi @ademmler,
The warning you get is probably related to a different section of the code, it is coming from the colour.models.eotf_inverse_sRGB definition.
Multiplying two spectral distributions should be straightforward: You simply multiply one with the other! There is one important thing to consider though: Whether their spectral shapes are the same.
NaNs
where the bins do not match.colour.SpectralDistribution
is built on top of a continuous signal representation and thus evaluate that function on the wavelengths of interest.