-
Notifications
You must be signed in to change notification settings - Fork 97
/
cmfrgb.m
64 lines (58 loc) · 2.58 KB
/
cmfrgb.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
%CMFRGB RGB color matching function
%
% The color matching function is the RGB tristimulus required to match a
% particular spectral excitation.
%
% RGB = CMFRGB(LAMBDA) is the CIE color matching function (Nx3) for illumination
% at wavelength LAMBDA (Nx1) [m]. If LAMBDA is a vector then each row of RGB
% is the color matching function of the corresponding element of LAMBDA.
%
% RGB = CMFRGB(LAMBDA, E) is the CIE color matching (1x3) function for an
% illumination spectrum E (Nx1) defined at corresponding wavelengths
% LAMBDA (Nx1).
%
% Notes::
% - Data from http://cvrl.ioo.ucl.ac.uk
% - From Table I(5.5.3) of Wyszecki & Stiles (1982). (Table 1(5.5.3)
% of Wyszecki & Stiles (1982) gives the Stiles & Burch functions in
% 250 cm-1 steps, while Table I(5.5.3) of Wyszecki & Stiles (1982)
% gives them in interpolated 1 nm steps.)
% - The Stiles & Burch 2-deg CMFs are based on measurements made on
% 10 observers. The data are referred to as pilot data, but probably
% represent the best estimate of the 2 deg CMFs, since, unlike the CIE
% 2 deg functions (which were reconstructed from chromaticity data),
% they were measured directly.
% - These CMFs differ slightly from those of Stiles & Burch (1955). As
% noted in footnote a on p. 335 of Table 1(5.5.3) of Wyszecki &
% Stiles (1982), the CMFs have been "corrected in accordance with
% instructions given by Stiles & Burch (1959)" and renormalized to
% primaries at 15500 (645.16), 19000 (526.32), and 22500 (444.44) cm-1
%
% References::
% - Robotics, Vision & Control, Section 10.2,
% P. Corke, Springer 2011.
%
% See also CMFXYZ, CCXYZ.
% Copyright (C) 1993-2011, by Peter I. Corke
%
% This file is part of The Machine Vision Toolbox for Matlab (MVTB).
%
% MVTB is free software: you can redistribute it and/or modify
% it under the terms of the GNU Lesser General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% MVTB is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU Lesser General Public License for more details.
%
% You should have received a copy of the GNU Leser General Public License
% along with MVTB. If not, see <http://www.gnu.org/licenses/>.
function rgb = cmfrgb(lambda, spect)
rgb = loadspectrum(lambda, 'cmfrgb.dat');
if nargin == 2
% approximate rectangular integration
dlambda = lambda(2) - lambda(1);
rgb = spect(:)' * rgb / numrows(rgb) * dlambda;
end