function [XYZValues, XYZWhitePoint] = rgb2xyz(RGBValues, RGBWhitePoint)
% [XYZValues, XYZWhitePoint] = rgb2xyz(RGBValues, RGBWhitePoint)
% Converts RGB values to XYZ values assuming some standard phosphors.
%
%   XYZValues = nx3 matrix of XYZ values
%   XYZWhitePoint = 1x3 vector of XYZ value for white point
%
%   RGBValues = nx3 matrix of RGB values
%   RGBWhitePoint = 1x3 vector of RGB value for white point

% Create RGB-to-XYZ transformation
monitorData = load('monitor.mat');
phosphors = monitorData.phosphors;
XYZData = load('XYZ.mat');
XYZ = XYZData.data;
RGB2XYZ = XYZ.' * phosphors;

% Transform input RGB values to output XYZ values
XYZValues = (RGB2XYZ * RGBValues.').';
XYZWhitePoint = (RGB2XYZ * RGBWhitePoint.').';
