File: GamutToSettings.m

package info (click to toggle)
psychtoolbox-3 3.0.19.14.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 86,796 kB
  • sloc: ansic: 176,245; cpp: 20,103; objc: 5,393; sh: 2,753; python: 1,397; php: 384; makefile: 193; java: 113
file content (44 lines) | stat: -rw-r--r-- 1,629 bytes parent folder | download | duplicates (6)
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
function settings = GamutToSettings(cal, gamut)
% settings = GamutToSettings(cal, gamut)
%
% Find the best device settings to produce
% the passed linear device coordinates.
% 
% The passed coordinates should be in the range [0,1].
% The returned settings also run from [0,1], but after
% inversion of the device's gamma measurements.
%
% The returned argument values is what you actually should
% get after quantization error.
%
% 9/26/93    dhb   Added calData argument.
% 10/19/93   dhb   Allow gamma table dimensions to exceed device settings.
% 11/11/93   dhb   Update for new calData routines.
% 8/4/96     dhb   Update for stuff bag routines.
% 8/21/97    dhb   Update for structures.
% 4/13/02	 awi   Replaced SettingsToDevice with new name SettingsToPrimary.
% 11/16/06   dhb   Adjust for [0,1] world.  Involves changing what's passed
%                  in and out
% 5/26/12    dhb   Add gammaMode == 2 case.

% Error checking
if isempty(cal.gammaTable)
	error('No gamma table present in calibration structure');
end
if isempty(cal.gammaMode)
	error('SetGammaMethod has not been called on calibration structure');
end

if cal.gammaMode == 0
	settings = GamutToSettingsSch(cal.gammaInput, cal.gammaTable, gamut);
elseif cal.gammaMode == 1
	%iGammaTable = cal.iGammaTable;
	if isempty(cal.iGammaTable)
		error('Inverse gamma table not present for gammaMode == 1');
	end
	settings = GamutToSettingsTbl(cal.iGammaTable, gamut);
elseif cal.gammaMode == 2
    settings = GamutToSettingsExhaust(cal.gammaInput, cal.gammaTable, gamut);
else
	error('Requested gamma inversion mode %g is not yet implemented', cal.gammaMode);
end