File: XYZToxyY.m

package info (click to toggle)
psychtoolbox-3 3.0.18.12.dfsg1-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 83,576 kB
  • sloc: ansic: 173,181; cpp: 20,885; objc: 5,148; sh: 2,752; python: 1,366; php: 384; makefile: 193; java: 113
file content (20 lines) | stat: -rw-r--r-- 424 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
function [xyY] = XYZToxyY(XYZ)
% [xyY] = XYZToxyY(XYZ)
%
% Compute chromaticity and luminance from
% from tristimulus values.
%
% 8/24/09  dhb  Speed it up vastly for large arrays.

denom = sum(XYZ,1);
xy = XYZ(1:2,:)./denom([1 1]',:);
xyY = [xy ; XYZ(2,:)];

% [m,n] = size(XYZ);
% xyY = zeros(m,n);
% for i = 1:n
%  xyY(1,i) = XYZ(1,i)./sum(XYZ(:,i));
%  xyY(2,i) = XYZ(2,i)./sum(XYZ(:,i));
%  xyY(3,i) = XYZ(2,i);
% end