function ls = OurLMSToMacBoyn2(LMS,T_cones,T_lum, s_scaler)
% ls = OurLMSToMacBoyn2(LMS,T_cones,T_lum, S_scaler)
% "2"となっているのは、同じ名前の自前の関数との混同を避けるため
%
% 以下、LMSToMacBoyn.mのhelp
%
% 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.

% 04/06/15	ek	fundamentalsによらず、分光視感効率と錐体分光感度に応じてスケーリング

if isempty(s_scaler)
	s_scaler = 1;
end;

% Scale LMS so that L+M = luminance
factors = (T_cones(1:2,:)'\T_lum');
LMS = diag([factors ; s_scaler])*LMS;

denom = [1 1 0]*LMS;
ls = LMS([1 3],:) ./ ([1 1]'*denom);
