File: LabToXYZ.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 (27 lines) | stat: -rw-r--r-- 663 bytes parent folder | download | duplicates (7)
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
function XYZ = LabToXYZ(Lab,whiteXYZ)
% XYZ = LabToXYZ(Lab,whiteXYZ)
%
% Convert Lab to XYZ.
%
% 10/10/93    dhb   Converted from CAP C code.
% 5/9/02      dhb   Improved help

% Check sizes and allocate
[m,n] = size(Lab);

% Get Y from Lstar
Y = LxxToY(Lab,whiteXYZ);

% Compute F[1] = f(Y/Yn) from Y
% Because subroutine is a vector routine, we put in and get/
% back dummy values for X,Z
fakeXYZ = [Y ; Y ; Y];
F = XYZToF(fakeXYZ,whiteXYZ);

% Compute ratio[0], ratio[2] from a*,b*, and ratio[1] */
F(1,:) = (Lab(2,:)/500.0) + F(2,:);
F(3,:) = F(2,:) - (Lab(3,:)/200.0);
ratio = FToRatio(F);

% Compute XYZ from the ratios
XYZ = ratio .* (whiteXYZ*ones(1,n));