File: GamutToSettingsTbl.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 (35 lines) | stat: -rw-r--r-- 964 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
function [settings] = GamutToSettingsTbl(iGammaTable,gamut)
% [settings] = GamutToSettingsTbl(iGammaTable,gamut)
%
% Find the best integer device settings to produce
% the passed linear device coordinates. Use a precomputed
% inverse gamma table.
% 
% The passed coordinates should be in the range [0,1].
% The returned values run from [0,nlevels-1], where nlevels
% is the number of quantized levels available on the device.
%
% 1/21/95		dhb		Wrote it.
% 5/26/12       dhb     Remove reference in comments to a return value that does not exist.

% Get number of levels
[nLevels,ng] = size(iGammaTable);

% Check dimensions and table sizes
[m,n] = size(gamut);
if (m > ng)
  error('Mismatch between device coordinate dimensions and gamma table');
end

% Use table lookup to find the answers
epsilon = 1/(100*nLevels);
indices = fix((gamut*nLevels)-epsilon)+1;
settings = zeros(size(gamut));
for j = 1:m
	settings(j,:) = iGammaTable(indices(j,:)',j)';
end