function [computer_measurements,spectro_measurements,...
      fill_order,engines,printers,simPrintColors,...
      xyBestSpectrum] = LoadMeasurements(),

%================================
% Load MONITOR Measurements
%================================
   simPrintColors(1) = {'Not Simulated Colors'};
   simPrintColors(2) = {'Simulated Colors'};
 
   fill_order = [2 6 1 5 3 4]; % This order for RGBCMYK creates a closed surface
                               % used for fill commands

   %%%%%%%%% WHITE POINT %%%%%%%%%%%%%
   %==================================
   monitorWhitePointxyY = [.301 .358 183]';
   computer_measurements.whitepoint.XYZ = xyY2XYZ(monitorWhitePointxyY);
   computer_measurements.whitepoint.xy = monitorWhitePointxyY(1:2);
   computer_measurements.whitepoint.Lab = ...
      XYZ2LabT(computer_measurements.whitepoint.XYZ,...
      computer_measurements.whitepoint.XYZ);
 
 
   %%%%%%%% ADOBE DEFAULT ENGINE %%%%%%%%%%%%%%%%
   %=============================================
 
   engines(1).name = {'Adobe Default Engine'};
 
   %%%% Adobe Illustrator Printer Default
   %=====================================
   printers(1).name = {'Adobe Illustrator Printer Default'};
 
   AIPD_E1_NoSim_xyY = [.597, .363, 24.2; ...
                        .314, .590,  122; ...
                        .150, .071, 13.1; ...
                        .232, .311, 66.9; ...
                        .426, .263, 33.3; ...
                        .375, .537,  145; ...
                        .352, .505,  1.9;]';
 
   AIPD_E1_Sim_xyY = [.597, .364, 23.8; ...
                      .318, .576, 71.6; ...
                      .169, .108,  7.0; ...
                      .222, .309, 66.2; ...
                      .426, .246, 28.8; ...
                      .375, .538,  144; ...
                      .252, .604,  1.3;]';
 
   %%%% HP Color LaserJet
   %=====================
   printers(2).name = {'HP Color LaserJet'};
 
   HPCL_E1_NoSim_xyY = [.598, .362, 24.7; ...
                        .311, .590,  123; ...
                        .145, .068, 12.5; ...
                        .195, .224, 41.2; ...
                        .363, .215, 29.9; ...
                        .386, .531,  146; ...
                        .334, .466,  7.5;]';
 
   HPCL_E1_Sim_xyY = [.490, .385, 32.8; ...
                      .319, .540, 64.4; ...
                      .207, .200, 26.5; ...
                      .195, .225, 41.2; ...
                      .360, .221, 30.3; ...
                      .385, .532,  146; ...
                      .334, .466,  7.6;]';
 
   %%%% Kodak DS 1000 PS Clear Film
   %===============================
   printers(3).name = {'Kodak DS 1000 PS Clear Film'};
 
   KDSPS_E1_NoSim_xyY = [.600, .361, 23.9; ...
                         .314, .588,  129; ...
                         .145, .066, 12.3; ...
                         .223, .306, 78.3; ...
                         .328, .180, 27.7; ...
                         .385, .533,  151; ...
                         .305, .568,  2.4;]';
 
   KDSPS_E1_Sim_xyY = [.575, .377, 26.5; ...
                       .316, .584, 100; ...
                       .180, .132, 17.9; ...
                       .222, .304, 83.6; ...
                       .324, .179, 28.5; ...
                       .383, .535, 155; ...
                       .302, .567, 2.4]';
 
   %%%% RGB->CMYK and CMYK->RGB
   %===========================
   KDSPS_E1_Convert_xyY = [.491, .385, 33.6; ...
                           .323, .537, 66.0; ...
                           .209, .201, 27.7; ...
                           .211, .251, 50.6; ...
                           .356, .252, 39.3; ...
                           .390, .529,  135; ...
                           .318, .407, 19.7;]';
 
 
 
   %%%%%%%% KODAK DIGITAL SCIENCE ICC CMS ENGINE %%%%%%%%%%%%%%%%
   %=============================================================
 
   engines(2).name = {'Kodak Digital Science ICC CMS'};
 
   %%%% Adobe Illustrator Printer Default
   %=====================================
 
   AIPD_E2_NoSim_xyY = [.600, .362, 24.7; ...
                        .312, .590,  125; ...
                        .149, .079, 14.4; ...
                        .225, .318, 65.3; ...
                        .438, .255, 30.0; ...
                        .379, .535,  149; ...
                        .259, .600,  1.4;]';
 
   AIPD_E2_Sim_xyY = [.596, .365, 24.7; ...
                      .319, .576, 77.7; ...
                      .168, .108,  6.7; ...
                      .224, .312, 67.7; ...
                      .432, .248, 30.6; ...
                      .377, .535,  151; ...
                      .256, .592,  1.4;]';
 
   %%%% HP Color LaserJet
   %=====================
   HPCL_E2_NoSim_xyY = [.597, .364, 25.2; ...
                        .312, .590,  129; ...
                        .145, .066, 13.1; ...
                        .196, .224, 43.6; ...
                        .355, .208, 29.7; ...
                        .384, .533,  154; ...
                        .333, .467,  7.9;]';
 
   HPCL_E2_Sim_xyY = [.489, .391, 34.4; ...
                      .320, .537, 64.4; ...
                      .207, .197, 26.1; ...
                      .197, .226, 43.5; ...
                      .369, .219, 33.3; ...
                      .390, .528,  157; ...
                      .336, .468,  8.1;]';
 
   %%%% Kodak DS 1000 PS Clear Film
   %===============================
 
   KDSPS_E2_NoSim_xyY = [.603, .358, 27.9; ...
                         .311, .590,  140; ...
                         .145, .068, 11.0; ...
                         .227, .319, 77.3; ...
                         .339, .187, 28.0; ...
                         .386, .531,  150; ...
                         .302, .535,  1.9;]';

   KDSPS_E2_Sim_xyY = [.579, .373, 26.1; ...
                       .319, .581, 99.6; ...
                       .179, .134, 16.1; ...
                       .222, .306, 78.3; ...
                       .332, .181, 28.9; ...
                       .386, .530,  150; ...
                       .309, .539,  2.0;]';
 

   %%%% RGB->CMYK and CMYK->RGB
   %===========================
   KDSPS_E2_Convert_xyY = [.485, .389, 31.7; ...
                           .326, .533, 62.9; ...
                           .208, .198, 26.8; ...
                           .213, .252, 46.6; ...
                           .364, .250, 39.1; ...
                           .389, .525,  128; ...
                           .318, .411, 19.3;]';
 
 
 
   tempCompxyY  = [AIPD_E1_NoSim_xyY, ...
                   AIPD_E1_Sim_xyY, ...
                   HPCL_E1_NoSim_xyY, ...
                   HPCL_E1_Sim_xyY, ...
                   KDSPS_E1_NoSim_xyY, ...
                   KDSPS_E1_Sim_xyY, ...
                   AIPD_E2_NoSim_xyY,  ...
                   AIPD_E2_Sim_xyY,  ...
                   HPCL_E2_NoSim_xyY, ...
                   HPCL_E2_Sim_xyY, ...
                   KDSPS_E2_NoSim_xyY,  ...
                   KDSPS_E2_Sim_xyY,  ...
                   KDSPS_E1_Convert_xyY,  ...
                   KDSPS_E2_Convert_xyY];
 

%=========================================================
% Convert ALL measurements to XYZ, xy, and Lab coordinates
%=========================================================

tempCompXYZ = xyY2XYZ(tempCompxyY);
tempCompLab = XYZ2LabT(tempCompXYZ,computer_measurements.whitepoint.XYZ);

for engineInd = 1:2,
   for printerInd = 1:3,
      for simInd = 1:2,
         i = ((engineInd-1)*6+(printerInd-1)*2+simInd-1)*7+1;
         computer_measurements.engine(engineInd).printer(printerInd).simPrintColors(simInd).XYZ = tempCompXYZ(:,i:i+6);
         computer_measurements.engine(engineInd).printer(printerInd).simPrintColors(simInd).xy = tempCompxyY(1:2,i:i+6);
         computer_measurements.engine(engineInd).printer(printerInd).simPrintColors(simInd).Lab = tempCompLab(:,i:i+6);
         computer_measurements.engine(engineInd).printer(printerInd).simPrintColors(simInd).convertXYZ = [];
         computer_measurements.engine(engineInd).printer(printerInd).simPrintColors(simInd).convertxy = [];
         computer_measurements.engine(engineInd).printer(printerInd).simPrintColors(simInd).convertLab = [];
      end
   end
end

computer_measurements.engine(1).printer(3).simPrintColors(2).convertXYZ = tempCompXYZ(:,85:91);
computer_measurements.engine(2).printer(3).simPrintColors(2).convertXYZ = tempCompXYZ(:,92:98);

computer_measurements.engine(1).printer(3).simPrintColors(2).convertxy = tempCompxyY(1:2,85:91);
computer_measurements.engine(2).printer(3).simPrintColors(2).convertxy = tempCompxyY(1:2,92:98);

computer_measurements.engine(1).printer(3).simPrintColors(2).convertLab = tempCompLab(:,85:91);
computer_measurements.engine(2).printer(3).simPrintColors(2).convertLab = tempCompLab(:,92:98);
 

%================================================
% Load Measurements Made by the Spectroradiometer
% And convert to XYZ, xy, and Lab Coordinates
%================================================

% This loads four variables: AllSpectra, color_order, printer_order, wavelength,
% and WhiteSpectrum.  AllSpectra is a 101X56 matrix of the measured spectra in
% this order: Printer1 Engine1 RGBCMYK, Printer1 Engine2 RGBCMYK,
% Printer2 Engine1 RGBCMYK, Printer2 Engine2 RGBCMYK, etc.
% WhiteSpectrum is the spectrum of our white point.
load spectra;
wavelengthspec = wavelength;
load xyz;
wavelengthxyz = wavelength;

% xyz and spectra have different wavelength parameters, so adjust accordingly:
minWavelength = max(min(wavelengthspec),min(wavelengthxyz));
maxWavelength = min(max(wavelengthspec),max(wavelengthxyz));
newWavelength = minWavelength:4:maxWavelength;
specindex = 1:length(newWavelength);
xyzindex = 1:4:4*length(newWavelength);
xyzoffset = min(newWavelength) - min(wavelengthxyz);
if (xyzoffset < 0),
  xyzoffset = 0;
end

load D65;
D65index = xyzindex;
D65offset = xyzoffset;

D65 = D65(D65offset+D65index,:);
xyz = xyz(xyzoffset+xyzindex,:);
AllSpectra = AllSpectra(specindex,:);
whiteSpectrum = whiteSpectrum(specindex,:);
%=========================================
% Adjust our spectra for white light, D65
%=========================================
AllSpectra = AllSpectra.*repmat(D65./whiteSpectrum,1,56);
whiteSpectrum = D65;
%=======================
% Calculate XYZ and xy
%=======================
AllXYZ = (xyz)'*AllSpectra;
xy = chromaticity(AllXYZ);

%================================
% Calculate Spectro White Point
%================================
spectro_measurements.whitepoint.XYZ = ...
   (xyz)'*whiteSpectrum;
spectro_measurements.whitepoint.xy = ...
   chromaticity(spectro_measurements.whitepoint.XYZ);
spectro_measurements.whitepoint.Lab = ...
   XYZ2LabT(spectro_measurements.whitepoint.XYZ,spectro_measurements.whitepoint.XYZ);

%=================
% Calculate Lab
%=================
lab = XYZ2labT(AllXYZ,spectro_measurements.whitepoint.XYZ);

% And Calculate best spectrum for comparison
xyBestSpectrum = chromaticity(xyz');
xyBestSpectrum = [xyBestSpectrum xyBestSpectrum(:,1)];

for printerInd = 1:3,
   for engineInd = 1:2,
      i = (printerInd-1)*14+(engineInd-1)*7+1;
      spectro_measurements.engine(engineInd).printer(printerInd).XYZ = AllXYZ(:,i:i+6);
      spectro_measurements.engine(engineInd).printer(printerInd).xy = xy(:,i:i+6);
      spectro_measurements.engine(engineInd).printer(printerInd).Lab = lab(:,i:i+6);
      spectro_measurements.engine(engineInd).printer(printerInd).convertXYZ = [];
      spectro_measurements.engine(engineInd).printer(printerInd).convertxy = [];
      spectro_measurements.engine(engineInd).printer(printerInd).convertLab = [];
   end
end

% These convert__ variables contain the data for RGB->CMYK conversion
% and vice versa.
spectro_measurements.engine(1).printer(3).convertXYZ = AllXYZ(:,43:49);
spectro_measurements.engine(2).printer(3).convertXYZ = AllXYZ(:,50:56);

spectro_measurements.engine(1).printer(3).convertxy = xy(:,43:49);
spectro_measurements.engine(2).printer(3).convertxy = xy(:,50:56);

spectro_measurements.engine(1).printer(3).convertLab = lab(:,43:49);
spectro_measurements.engine(2).printer(3).convertLab = lab(:,50:56);