% function[out]=Rgb2XyzFirstOrder(img,colorTrans);
% Input: img, an RGB image, size = rows*cols*3
%        colorTrans, a 3x3 linear transformation matrix from RGB
%        to XYZ space.
% Output: out, an XYZ image
%
% Uses colorTrans transformation matrix to transform input RGB
% values to CIE-XYZ values.
%

function[out]=Rgb2XyzFirstOrder(img,colorTrans);

[rows,cols,colors]=size(img);
if(colors~=3) 
  error('ERROR(Rgb2XyzFirstOrder): Input must be three color image!') 
end
img=reshape(img,rows*cols,3);
out = colorTrans*img';
out = reshape(out',rows,cols,3);
