/usr/share/psychtoolbox-3/PsychCal/PrimaryToGamut.m is in psychtoolbox-3-common 3.0.14.20170103+git6-g605ff5c.dfsg1-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | function [gamut, badIndex] = PrimaryToGamut(cal,primary)
% [gamut, badIndex] = PrimaryToGamut(cal,primary)
%
% Check that primary coordinates are in range [0,1].
% Force them to be so if not. The indices of the
% out of gamut primary settings are returned as 'badIndex'.
%
% 9/8/93 jms Set global flag if there was a gamut problem.
% 9/13/93 jms Took out the global flag and instead return
% a flag vector for the ones that were changed.
% 9/26/93 dhb Added calData argument. It is not used, but
% I want to pass it through these routines generally
% 9/27/93 jms Commented out the messages for going out of gamut.
% 3/7/94 dhb Modified so that badIndex return respects tolerance.
% 4/5/02 dhb, ly New naming convention.
gamut = primary;
tolerance = 1e-10;
[m,n] = size(primary);
badIndex = zeros(1,n);
% Check lower bound by rows
for (i=1:m)
index = find(primary(i,:) < 0);
if (~isempty(index))
gamut(i,index) = zeros(1,length(index));
index = find(primary(i,:) < -tolerance);
if (~isempty(index))
badIndex(index) = ones(1,length(index));
end
end
end
% Check upper bound by rows
for (i=1:m)
index = find(primary(i,:) > 1);
if (~isempty(index))
gamut(i,index) = ones(1,length(index));
index = find(primary(i,:) > 1+tolerance);
if (~isempty(index))
badIndex(index) = ones(1,length(index));
end
end
end
|