File: SetGammaMethod.m

package info (click to toggle)
psychtoolbox-3 3.0.9%2Bsvn2579.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 63,408 kB
  • sloc: ansic: 73,310; cpp: 11,139; objc: 3,129; sh: 1,669; python: 382; php: 272; makefile: 172; java: 113
file content (37 lines) | stat: -rw-r--r-- 1,096 bytes parent folder | download
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
function cal = SetGammaMethod(cal,gammaMode,precision)
% cal = SetGammaMethod(cal,gammaMode,[precision])
%
% Set up the gamma correction mode to be used.  Options
% are:
%   gammaMode == 0 - exhaustive table search.  Accurate but slow.
%   gammaMode == 1 - inverse table lookup.  Fast but less accurate.
%
% If gammaMode == 1, then you may specify the precision of the
% inverse table.  The default is 1000 levels.
%
% 8/4/96  dhb  Wrote it.
% 8/21/97 dhb  Update for structure.
% 3/12/98 dhb  Change name to SetGammaCorrectMode

% Check that the needed data is available. 
gammaTable = cal.gammaTable;
gammaInput = cal.gammaInput;
if isempty(gammaTable)
	error('Calibration structure does not contain gamma data');
end

% Do the right thing depending on mode.
if gammaMode == 0
	cal.gammaMode = gammaMode;
	return;
elseif gammaMode == 1
	if nargin == 2
		precision = 1000;
	end
	iGammaTable = InvertGammaTable(gammaInput,gammaTable,precision);
	cal.gammaMode = gammaMode;
	cal.iGammaTable = iGammaTable;
else
  error('Requested gamma inversion mode %g is not yet implemented', gammaMode);
end