function imlab = imagetolab(imxyz)

%% imlab = imagetolab(imxyz)
%%
%% This function accepts as input an [n x m x 3] image matrix of XYZ
%% values, performs the conversion to L*a*b* for each pixel, and returns
%% an image of L*a*b* values.
%%
%% created: JSB 6/13/00

[n m p] = size(imlin);

imlab = zeros(n,m,3);
xyzrow = zeros(3,m);
labrow = zeros(3,m);

for i = 1:n
	for j = 1:m
		xyzrow(1,j) = imxyz(i,j,1);
		xyzrow(2,j) = imxyz(i,j,2);
		xyzrow(3,j) = imxyz(i,j,3);
	end
	labrow = tolab(xyzrow);
	for j = 1:m
		imlab(i,j,1) = labrow(1,j);
		imlab(i,j,2) = labrow(2,j);
		imlab(i,j,3) = labrow(3,j);
	end
end
