United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 6523402 OSS CMM: Some quality problems with GRAY, PYCC and CIEXYZ color spaces with lcms library
6523402 : OSS CMM: Some quality problems with GRAY, PYCC and CIEXYZ color spaces with lcms library

Details
Type:
Bug
Submit Date:
2007-02-09
Status:
Open
Updated Date:
2012-10-18
Project Name:
JDK
Resolved Date:
Component:
client-libs
OS:
generic
Sub-Component:
2d
CPU:
generic
Priority:
P4
Resolution:
Unresolved
Affected Versions:
7
Targeted Versions:
8

Related Reports

Sub Tasks

Description
Here is tolerance values that used for comparing results of the color transformations with ones obtained from original Kodak color management system:

Color Space   Tolerance 

sRGB               3     
LINEAR_RGB         7         
GRAY              11
PYCC              46
CIEXYZ            48
There are some quality problems with following color spaces:  GRAY(not so noticeable), PYCC  and  CIEXYZ. Because of that following regression test is using large tolerance values for checking the result of transformations:

test/sun/java2d/cmm/ColorConvertOp/ColConvCCMTest.java

                                    

Comments
EVALUATION

This problem happens because inaccuracy inside the littleCMS library. The same inaccuracy happens with both jdk and openJDK color profiles. Here is minimized java and native testcases showing the problem with GRAY -> sRGB transform.

--------------GrayTest.java------------------
import java.awt.color.ColorSpace;

public class GrayTest {
    final static int [] cols = {1, 2, 3, 4, 5, 6, 7};
    
    public static void main(String [] args) {
        ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
        float [] p = new float[1];
        for (int i = 0; i < cols.length; i++) {
            p[0] = cols[i]/255.0f;
            float [] r = cs.toRGB(p);
            for (int j = 0; j < r.length; j++) {
                System.out.print((int)(r[j]*255) + ",");
            }
            System.out.println();
        }
    }
}

-------------------gray.cpp---------------------
#include <stdio.h>
#include "lcms.h"

char pixels[] = {1, 2, 3, 4, 5, 6, 7};

int main(int argc, char* argv[]) {
    char* in = pixels;
    char out[3];

    cmsHPROFILE profiles[2];
    profiles[0] = cmsOpenProfileFromFile("KCMS\\GRAY.pf", "r");

    profiles[1] = cmsOpenProfileFromFile("KCMS\\sRGB.pf", "r");

    cmsHTRANSFORM trans = cmsCreateMultiprofileTransform(
        profiles,2,BYTES_SH(1) | CHANNELS_SH(1), BYTES_SH(1) | CHANNELS_SH(3),
        0/* perceptual*/,0);

    for (int i = 0; i < sizeof(pixels)/sizeof(char); i++) {

        cmsDoTransform(trans, in++, out, 1);

        printf("%d,%d,%d\n", out[0], out[1], out[2]);
    }

}

output from JDK6,7 with GrayTest:

12,12,12,
21,21,21,
28,28,28,
33,33,33,
38,38,38,
42,42,42,
46,46,46,

output from openJDK with GrayTest and native testcase:

6,6,6,
12,12,12,
18,18,18,
24,24,24,
31,31,31,
37,37,37,
43,43,43,
                                     
2007-03-06



Hardware and Software, Engineered to Work Together