frudawski

spec2srgb

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:

ParameterDescription
srgbContains the returned colour n\times 3 matrix.
lamSpecifies the wavelengths, vector.
specDefines the spectral power distirubtion, vector or matrix.
mode
(optional)
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
(optional)
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:

IEC 61966-2-1:1999: Multimedia systems and equipment - Colour measurement and management - Part 2-1: Colour management - Default RGB colour space - sRGB. International Electrotechnical Commission (IEC), Geneva, Switzerland, 1999.

Leave a comment

* I accept the use of cookies as well as the terms in the privacy policy. I accept that data provided by me is processed and saved. I know and accept that comments may be saved and published after review.