% rgb22hsi_function
function yy  =rgb22hsi_fun(xr,xg,xb)
%
n=0.5*((xr-xg)+(xr-xb));
d=sqrt((xr-xg).^2 + (xr-xb).*(xg-xb));
H=acos(n./(d+eps));
H(xb>xg)=2*pi-H(xb>xg);
H=H/(2*pi);
%
n=3*min(min(xr,xb),xg);
d=xr+xg+xb;
S=1-n./(d+eps);
H(S==0)=0;
%
I=(xr+xb+xg)/3;
yy=cat(3,H,S,I);

