Spectrum to rgb color conversion

Description

Calculates rgb values from spectra based on human color matching functions (CMF) or chromaticity coordinates (CC). A CMF takes into account luminous sensitivity, while a CC only the color hue. This function, in contrast to that in package pavo does not normalize the values to equal luminosity, so using a CMF as input gives the expected result. Another difference is that it allows the user to choose the chromaticity data to be used. The data used by default is different, and it corresponds to the whole range of CIE standard, rather than the reduced range 400 nm to 700 nm. The wavelength limits are not hard coded, so the function could be used to simulate vision in other organisms as long as pseudo CMF or CC data are available for the simulation.

Usage

1
2
s_e_irrad2rgb(w.length, s.e.irrad, sens = photobiology::ciexyzCMF2.spct,
  color.name = NULL, check = TRUE)

Arguments

w.length

numeric array of wavelengths (nm)

s.e.irrad

numeric array of spectral irradiance values

sens

a chroma_spct object with variables w.length, x, y, and z, giving the CC or CMF definition (default is the proposed human CMF according to CIE 2006.)

color.name

character string for naming the rgb color definition

check

logical indicating whether to check or not spectral data

Value

A color defined using rgb. The numeric values of the RGB components can be obtained using function col2rgb.

Note

Very heavily modified from Chad Eliason's cme16@zips.uakron.edu spec2rgb function in package Pavo.

References

CIE(1932). Commission Internationale de l'Eclairage Proceedings, 1931. Cambridge: Cambridge University Press.

Color matching functions obtained from Colour and Vision Research Laboratory online data respository at http://www.cvrl.org/.

See Also

http://www.cs.rit.edu/~ncs/color/t_spectr.html.

Other color functions: rgb_spct, w_length2rgb, w_length_range2rgb

Examples

1
2
3
my.color <-
    with(sun.data, s_e_irrad2rgb(w.length, s.e.irrad, color.name="sunWhite"))
col2rgb(my.color)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.