File: SensorToPrimary.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 (41 lines) | stat: -rw-r--r-- 1,267 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
function [primary] = SensorToPrimary(cal,sensor)
% [primary] = SensorToPrimary(cal,sensor)
%
% Convert from sensor color space coordinates to primary
% coordinates.
%
% This depends on the standard calibration globals.
%
% 9/26/93    dhb   Added calData argument.
% 10/19/93   dhb   Allow device characterization dimensions to exceed
%                  linear settings dimensions.
% 11/11/93   dhb   Update for new calData routines.
% 11/17/93   dhb   Newer calData routines.
% 8/4/96     dhb   Update for stuff bag routines.
% 8/21/97    dhb   Update for structures.
% 4/5/02     dhb, ly  New calling convention.  Internal naming not changed fully.


% Get size
[m,n] = size(sensor);

% Get necessary calibration data
M_linear_device = cal.M_linear_device;
ambient_linear = cal.ambient_linear;
if (isempty(M_linear_device) || isempty(ambient_linear))
	error('SetSensorColorSpace has not been called on calibration structure');
end

% Ambient corrections
[ma,na] = size(ambient_linear);
if (m ~= ma || na ~= 1)
  error('Incorrect dimensions for ambient');
end
sensora = sensor-ambient_linear*ones(1,n);

% Color space conversion
[mm,nm] = size(M_linear_device);
if (m > nm)
  error ('Incorrect dimensions for M_linear_device');
end
primary = M_linear_device*sensora;