The spec2srgb function transforms spectra to MATLAB/Octave srgb values and includes a gamma correction based on the spectra’s Y values and a rough white balancing.
Note: standard whitepoint for sRGB is ‘D65’
Usage:
srgb = spec2srgb(lam,spec,mode,wp)
Where:
Parameter | Description |
srgb | Contains the returned colour n\times 3 matrix. |
lam | Specifies the wavelengths, vector. |
spec | Defines the spectral power distirubtion, vector or matrix. |
mode | allows for rough white balancing: ‘none’ default ‘obj’ reflectant object colours, normalized at total maximum brightness ‘lum’ luminous object colours, each colour maximized in brightness |
wp | Defines the reference whitepoint char or vector triplet. Default: ‘D65’, see ciewhitepoint |
Examples
Plot the CIE colour rendering index reference colours:
lam = 380:780; spec = ciespec(lam,'CRI'); srgb = spec2srgb(lam,spec); plotcolour(srgb)
See also: ciespec, plotcolour
Result:
Plot luminous colours for planck radiators with different temperatures between 3000 K and 10000 K:
T = linspace(3000,10000,9) lam = 360:830; spec = planck(T,lam); srgb = spec2srgb(lam,spec,'lum'); plotcolour(srgb)
See also: planck, plotcolour
Result:
T = 3000 3875 4750 5625 6500 7375 8250 9125 10000
Plot colours of different daylight illuminants and change whitepoint to ‘D75’:
lam = 380:780; spec = ciespec(lam,{'D50','D55','D65','D75','D95'}); srgb = spec2srgb(lam,spec,'lum','D75'); plotcolour(srgb)
See also: ciespec, plotcolour
Result:
Reference: