Reputation: 137
I search for some Python library that can find color temperature from spectral response from spectrometer. I have single spectrum output like this:
I want to find color temperate of my light source.
The outputs shuld be like here (values not plot):
I searched a lot but I didn't find anything, in libraries like colour-science or python-colormath I don't see option like that. Is it possible at all?
Upvotes: 2
Views: 1987
Reputation: 4080
It is certainly possible with Colour:
>>> import colour
>>> D65 = colour.ILLUMINANTS_SDS['D65']
>>> XYZ = colour.sd_to_XYZ(D65)
>>> xy = colour.XYZ_to_xy(XYZ)
>>> colour.xy_to_CCT(xy)
6507.5108766555786
Or with the Automatic Colour Conversion Graph:
>>> import colour
>>> colour.convert(D65, 'Spectral Distribution', 'CCT', sd_to_XYZ={'illuminant': colour.sd_ones()})
6507.5108766555786
You have to specify an illuminant here to override the default which happens to be D65 :)
Upvotes: 2
Reputation: 3437
The process normally takes the following steps:
There is an explanation and code here.
Update
You may prefer to use this project: https://github.com/aerobio/spectra/
Upvotes: 2