%Convert row vectors of XYZ tristimulus values to LAB values
%If necessary, the input should be reshaped into an N by 3 array before 
%calling this routine.
%Uses the function f_xyz2lab
%Reference white is assumed to be D65
function LAB = XYZ2LAB(XYZ)
W = [.9505 1 1.0891]; %D65
LAB(:,1) = 116*f_xyz2lab(XYZ(:,2)/W(2))-16;
LAB(:,2) = 500*(f_xyz2lab(XYZ(:,1)/W(1))- f_xyz2lab(XYZ(:,2)/W(2)));
LAB(:,3) = 200*(f_xyz2lab(XYZ(:,2)/W(2))- f_xyz2lab(XYZ(:,3)/W(3)));