Brixomatic commented on a change in pull request #114:
URL: https://github.com/apache/commons-imaging/pull/114#discussion_r548983060



##########
File path: src/main/java/org/apache/commons/imaging/color/ColorConversions.java
##########
@@ -99,8 +89,8 @@ public static ColorHunterLab convertXYZtoHunterLab(final 
ColorXyz xyz) {
     public static ColorHunterLab convertXYZtoHunterLab(final double X,
             final double Y, final double Z) {
         final double L = 10 * Math.sqrt(Y);
-        final double a = 17.5 * (((1.02 * X) - Y) / Math.sqrt(Y));
-        final double b = 7 * ((Y - (0.847 * Z)) / Math.sqrt(Y));
+        final double a = Y == 0.0 ? 0.0 : 17.5 * (((1.02 * X) - Y) / 
Math.sqrt(Y));
+        final double b = Y == 0.0 ? 0.0 : 7 * ((Y - (0.847 * Z)) / 
Math.sqrt(Y));

Review comment:
       If Y == 0.0 (as with black color) "a" and "b" would become "NaN", this 
the same fix that colormine uses (see 
[HunterLabConverter.cs](https://github.com/muak/ColorMine/blob/master/ColorMine/ColorSpaces/Conversions/HunterLabConverter.cs)
 )




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to