[ 
https://issues.apache.org/jira/browse/IMAGING-283?focusedWorklogId=561918&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-561918
 ]

ASF GitHub Bot logged work on IMAGING-283:
------------------------------------------

                Author: ASF GitHub Bot
            Created on: 07/Mar/21 08:42
            Start Date: 07/Mar/21 08:42
    Worklog Time Spent: 10m 
      Work Description: Brixomatic commented on a change in pull request #114:
URL: https://github.com/apache/commons-imaging/pull/114#discussion_r588994104



##########
File path: src/main/java/org/apache/commons/imaging/color/ColorConversions.java
##########
@@ -168,30 +152,24 @@ public static ColorXyz convertRGBtoXYZ(final int rgb) {
         double var_G = g / 255.0; // Where G = 0 ÷ 255
         double var_B = b / 255.0; // Where B = 0 ÷ 255
 
-        if (var_R > 0.04045) {
-            var_R = Math.pow((var_R + 0.055) / 1.055, 2.4);
-        } else {
-            var_R = var_R / 12.92;
-        }
-        if (var_G > 0.04045) {
-            var_G = Math.pow((var_G + 0.055) / 1.055, 2.4);
-        } else {
-            var_G = var_G / 12.92;
-        }
-        if (var_B > 0.04045) {
-            var_B = Math.pow((var_B + 0.055) / 1.055, 2.4);
-        } else {
-            var_B = var_B / 12.92;
-        }
+        // Pivot RGB:
+        var_R = unPivotRGB(var_R);
+        var_G = unPivotRGB(var_G);
+        var_B = unPivotRGB(var_B);
 
-        var_R = var_R * 100;
-        var_G = var_G * 100;
-        var_B = var_B * 100;
+        var_R *= 100;
+        var_G *= 100;
+        var_B *= 100;
 
         // Observer. = 2°, Illuminant = D65
-        final double X = var_R * 0.4124 + var_G * 0.3576 + var_B * 0.1805;
-        final double Y = var_R * 0.2126 + var_G * 0.7152 + var_B * 0.0722;
-        final double Z = var_R * 0.0193 + var_G * 0.1192 + var_B * 0.9505;
+        // see: 
https://github.com/StanfordHCI/c3/blob/master/java/src/edu/stanford/vis/color/LAB.java
+        final double X = var_R * 0.4124564 + var_G * 0.3575761 + var_B * 
0.1804375;
+        final double Y = var_R * 0.2126729 + var_G * 0.7151522 + var_B * 
0.0721750;
+        final double Z = var_R * 0.0193339 + var_G * 0.1191920 + var_B * 
0.9503041;
+
+        // final double X = var_R * 0.4124 + var_G * 0.3576 + var_B * 0.1805;
+        // final double Y = var_R * 0.2126 + var_G * 0.7152 + var_B * 0.0722;
+        // final double Z = var_R * 0.0193 + var_G * 0.1192 + var_B * 0.9505;

Review comment:
       I left them over to make the change more apparent, since most sources 
just list the shorter value. If you like I will remove them. For the time 
being, I'll add a line of explanation.
   




----------------------------------------------------------------
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:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 561918)
    Time Spent: 40m  (was: 0.5h)

> Add CIELAB and DIN99 conversion, reduce code duplication, and issues related 
> to zero-division and precision
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: IMAGING-283
>                 URL: https://issues.apache.org/jira/browse/IMAGING-283
>             Project: Commons Imaging
>          Issue Type: Improvement
>          Components: imaging.color.*
>    Affects Versions: 1.0-alpha2
>            Reporter: Bruno P. Kinoshita
>            Assignee: Bruno P. Kinoshita
>            Priority: Major
>             Fix For: 1.0-alpha3
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> Placeholder for https://github.com/apache/commons-imaging/pull/114



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to