| |
- wavelen2rgb(Wavelength, MaxIntensity=100)
- Calculate RGB values given the wavelength of visible light.
Arguments:
* Wavelength: Wavelength in nm. Scalar floating.
* MaxIntensity: The RGB value for maximum intensity. Scalar
integer.
Returns:
* 3-element list of RGB values for the input wavelength. The
values are scaled from 0 to MaxIntensity, where 0 is the
lowest intensity and MaxIntensity is the highest. Integer
list.
Visible light is in the range of 380-780 nm. Outside of this
range the returned RGB triple is [0,0,0].
Based on code by Earl F. Glynn II at:
http://www.efg2.com/Lab/ScienceAndEngineering/Spectra.htm
See also:
http://www.physics.sfasu.edu/astro/color/spectra.html
whose code is what Glynn's code is based on.
Example:
>>> from wavelen2rgb import wavelen2rgb
>>> waves = [300.0, 400.0, 600.0]
>>> rgb = [wavelen2rgb(waves[i], MaxIntensity=255) for i in range(3)]
>>> print rgb
[[0, 0, 0], [131, 0, 181], [255, 190, 0]]
|