function imxyz = imagetoxyz(imlin)

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

[n m p] = size(imlin);

imxyz = zeros(n,m,3);
rgbrow = zeros(3,m);
xyzrow = zeros(3,m);

for i = 1:n
	for j = 1:m
		rgbrow(1,j) = imlin(i,j,1);
		rgbrow(2,j) = imlin(i,j,2);
		rgbrow(3,j) = imlin(i,j,3);
	end
	xyzrow = toxyz(rgbrow);
	for j = 1:m
		imxyz(i,j,1) = xyzrow(1,j);
		imxyz(i,j,2) = xyzrow(2,j);
		imxyz(i,j,3) = xyzrow(3,j);
	end
end




