From 376f0b4138133a7562083e3f72f58ef061dd23fc Mon Sep 17 00:00:00 2001 From: kupferb <33594117+kupferb@users.noreply.github.com> Date: Fri, 2 Feb 2024 01:10:43 +0200 Subject: [PATCH 1/2] Update colorspace.m added epsilon in luv computation to prevent NaNs for pixels that are zero in all channels --- others/colorspace.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/others/colorspace.m b/others/colorspace.m index 78667be..32a5f0d 100755 --- a/others/colorspace.m +++ b/others/colorspace.m @@ -339,10 +339,11 @@ 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)); +WhitePointU = (4*WhitePoint(1))./(eps1 + WhitePoint(1) + 15*WhitePoint(2) + 3*WhitePoint(3)); +WhitePointV = (9*WhitePoint(2))./(eps1 + 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)); From 06e11ccde4a1d78a6fbb41db7bb1a4e1c94f593a Mon Sep 17 00:00:00 2001 From: kupferb <33594117+kupferb@users.noreply.github.com> Date: Fri, 2 Feb 2024 01:15:14 +0200 Subject: [PATCH 2/2] Update colorspace.m added epsilon in luv computation to prevent NaNs for pixels that are zero in all channels --- others/colorspace.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/others/colorspace.m b/others/colorspace.m index 32a5f0d..6c815ec 100755 --- a/others/colorspace.m +++ b/others/colorspace.m @@ -342,12 +342,12 @@ eps1 = 1e-12 % Convert to CIE L*u*v* (CIELUV) WhitePoint = [0.950456,1,1.088754]; -WhitePointU = (4*WhitePoint(1))./(eps1 + WhitePoint(1) + 15*WhitePoint(2) + 3*WhitePoint(3)); -WhitePointV = (9*WhitePoint(2))./(eps1 + WhitePoint(1) + 15*WhitePoint(2) + 3*WhitePoint(3)); +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*