diff --git a/others/colorspace.m b/others/colorspace.m index 78667be..6c815ec 100755 --- a/others/colorspace.m +++ b/others/colorspace.m @@ -339,14 +339,15 @@ function Image = luv(Image,SrcSpace) +eps1 = 1e-12 % Convert to CIE L*u*v* (CIELUV) WhitePoint = [0.950456,1,1.088754]; WhitePointU = (4*WhitePoint(1))./(WhitePoint(1) + 15*WhitePoint(2) + 3*WhitePoint(3)); WhitePointV = (9*WhitePoint(2))./(WhitePoint(1) + 15*WhitePoint(2) + 3*WhitePoint(3)); Image = xyz(Image,SrcSpace); % Convert to XYZ -U = (4*Image(:,:,1))./(Image(:,:,1) + 15*Image(:,:,2) + 3*Image(:,:,3)); -V = (9*Image(:,:,2))./(Image(:,:,1) + 15*Image(:,:,2) + 3*Image(:,:,3)); +U = (4*Image(:,:,1))./(eps1+Image(:,:,1) + 15*Image(:,:,2) + 3*Image(:,:,3)); +V = (9*Image(:,:,2))./(eps1+Image(:,:,1) + 15*Image(:,:,2) + 3*Image(:,:,3)); Y = Image(:,:,2)/WhitePoint(2); L = 116*f(Y) - 16; Image(:,:,1) = L; % L*