File: LMSToMacBoyn.m

package info (click to toggle)
psychtoolbox-3 3.0.14.20170103%2Bgit6-g605ff5c.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 103,044 kB
  • ctags: 69,483
  • sloc: ansic: 167,371; cpp: 11,232; objc: 4,708; sh: 1,875; python: 383; php: 344; makefile: 207; java: 113
file content (29 lines) | stat: -rw-r--r-- 804 bytes parent folder | download | duplicates (3)
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
function ls = LMSToMacBoyn(LMS,T_cones,T_lum)
% ls = LMSToMacBoyn(LMS,[T_cones,T_lum])
%
% Compute MacLeod-Boynton chromaticity from
% cone coordinates.
%
% If T_cones and T_lum are not passed, we assume
% Smith-Pokorny sensitivities normalized to a
% peak of 1.  I T_cones and T_lum are passed,
% we compute the scalings of the L and M cones
% required to best predict lumiance and scale
% accordingly.
%
% 10/30/97  dhb  Wrote it.
% 7/9/02    dhb  T_cones_sp -> T_cones on line 20.  Thanks to Eiji Kimura.

% Scale LMS so that L+M = luminance
if (nargin == 1)
	LMS = diag([0.6373 0.3924 1]')*LMS;
else
	factors = (T_cones(1:2,:)'\T_lum');
	LMS = diag([factors ; 1])*LMS;
end

% Compute ls coordinates from LMS
n = size(LMS,2);
ls = zeros(2,n);
denom = [1 1 0]*LMS;
ls = LMS([1 3],:) ./ ([1 1]'*denom);