Calculates rgb values from spectra based on human colour matching functions.

spec2rgb(rspecdata, alpha = 1)

Arguments

rspecdata

(required) a data frame, possibly an object of class rspec that has wavelength range in the first column, named 'wl', and spectral measurements in the remaining columns.

alpha

alpha value to use for colors (defaults to 1, opaque).

Value

A character vector consisting of hexadecimal colour values for passing to further plotting functions.

References

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

Examples

data(teal) spec2rgb(teal)
#> Acrecca-1 Acrecca-2 Acrecca-3 Acrecca-4 Acrecca-5 Acrecca-6 #> "#24B461FF" "#00A65FFF" "#00945EFF" "#00825CFF" "#006E5CFF" "#00585AFF" #> Acrecca-7 Acrecca-8 Acrecca-9 Acrecca-10 Acrecca-11 Acrecca-12 #> "#084756FF" "#1A364EFF" "#222A44FF" "#24223AFF" "#2B2439FF" "#292230FF"
# Plot data using estimated perceived colour plot(teal, col = spec2rgb(teal), type = "o")