diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2015-08-23 12:17:05 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2015-08-23 12:17:05 +0200 |
commit | c0b89ac5bfb90835ef01573267020e42d4fe070c (patch) | |
tree | 733c16852d964d84b7565af4bdaff0bcca901b88 /profile/invprofcheck.c | |
parent | 094535c010320967639e8e86f974d878e80baa72 (diff) |
Imported Upstream version 1.8.0upstream/1.8.0
Diffstat (limited to 'profile/invprofcheck.c')
-rwxr-xr-x[-rw-r--r--] | profile/invprofcheck.c | 116 |
1 files changed, 108 insertions, 8 deletions
diff --git a/profile/invprofcheck.c b/profile/invprofcheck.c index 8cb9f34..5cb1101 100644..100755 --- a/profile/invprofcheck.c +++ b/profile/invprofcheck.c @@ -89,9 +89,12 @@ void usage(void) { fprintf(stderr," -v [level] verbosity level (default 1), 2 to print each DE\n"); fprintf(stderr," -l limit set total ink limit (estimate by default)\n"); fprintf(stderr," -L klimit set black channel ink limit (estimate by default)\n"); + fprintf(stderr," -i intent a = absolute, r = relative colorimetric (def.)\n"); + fprintf(stderr," p = perceptual, s = saturation\n"); fprintf(stderr," -h high res test (%d)\n",HTRES); fprintf(stderr," -u Ultra high res test (%d)\n",UHTRES); fprintf(stderr," -R res Specific grid resolution\n"); + fprintf(stderr," -I Do bwd to fwd check\n"); fprintf(stderr," -c Show CIE94 delta E values\n"); fprintf(stderr," -k Show CIEDE2000 delta E values\n"); fprintf(stderr," -w create %s visualisation (profile%s)\n",vrml_format(),vrml_ext()); @@ -124,9 +127,11 @@ main( icmFile *rd_fp; icc *icco; int rv = 0; + int inv = 0; int tres = TRES; double tlimit = -1.0; double klimit = -1.0; + icRenderingIntent intent = icRelativeColorimetric; /* Default */ vrml *wrl = NULL; error_program = "invprofcheck"; @@ -165,8 +170,8 @@ main( /* Resolution */ else if (argv[fa][1] == 'h' || argv[fa][1] == 'H') { tres = HTRES; - } + /* Resolution */ else if (argv[fa][1] == 'u' || argv[fa][1] == 'U') { tres = UHTRES; @@ -175,18 +180,23 @@ main( /* Resolution */ else if (argv[fa][1] == 'R') { int res; - fa = nfa; if (na == NULL) usage(); + fa = nfa; res = atoi(na); if (res < 2 || res > 500) usage(); tres = res; } + /* Inverse */ + else if (argv[fa][1] == 'I') { + inv = 1; + } + else if (argv[fa][1] == 'l') { int limit; - fa = nfa; if (na == NULL) usage(); + fa = nfa; limit = atoi(na); if (limit < 1) limit = 1; @@ -195,14 +205,36 @@ main( else if (argv[fa][1] == 'L') { int limit; - fa = nfa; if (na == NULL) usage(); + fa = nfa; limit = atoi(na); if (limit < 1) limit = 1; klimit = limit/100.0; } + /* Intent */ + else if (argv[fa][1] == 'i') { + if (na == NULL) usage(); + fa = nfa; + switch (na[0]) { + case 'p': + intent = icPerceptual; + break; + case 'r': + intent = icRelativeColorimetric; + break; + case 's': + intent = icSaturation; + break; + case 'a': + intent = icAbsoluteColorimetric; + break; + default: + usage(); + } + } + /* VRML/X3D */ else if (argv[fa][1] == 'w' || argv[fa][1] == 'W') dovrml = 1; @@ -235,7 +267,6 @@ main( if (fa >= argc || argv[fa][0] == '-') usage(); strncpy(in_name,argv[fa++],MAXNAMEL); in_name[MAXNAMEL] = '\000'; - strncpy(out_name,in_name,MAXNAMEL-4); out_name[MAXNAMEL-4] = '\000'; if ((xl = strrchr(out_name, '.')) == NULL) /* Figure where extention is */ xl = out_name + strlen(out_name); @@ -265,7 +296,7 @@ main( double nsamps = 0.0; /* Get a Device to PCS conversion object */ - if ((luo1 = icco->get_luobj(icco, icmFwd, icRelativeColorimetric, icSigLabData, icmLuOrdNorm)) == NULL) { + if ((luo1 = icco->get_luobj(icco, icmFwd, intent, icSigLabData, icmLuOrdNorm)) == NULL) { if ((luo1 = icco->get_luobj(icco, icmFwd, icmDefaultIntent, icSigLabData, icmLuOrdNorm)) == NULL) error ("%d, %s",icco->errc, icco->err); } @@ -273,7 +304,7 @@ main( luo1->spaces(luo1, &ins, &inn, &outs, &outn, NULL, NULL, NULL, NULL, NULL); /* Get a PCS to Device conversion object */ - if ((luo2 = icco->get_luobj(icco, icmBwd, icRelativeColorimetric, icSigLabData, icmLuOrdNorm)) == NULL) { + if ((luo2 = icco->get_luobj(icco, icmBwd, intent, icSigLabData, icmLuOrdNorm)) == NULL) { if ((luo2 = icco->get_luobj(icco, icmBwd, icmDefaultIntent, icSigLabData, icmLuOrdNorm)) == NULL) error ("%d, %s",icco->errc, icco->err); } @@ -309,7 +340,8 @@ main( printf("Input black ink limit assumed is %3.1f%%\n",100.0 * klimit); } - { + /* Device -> PCS -> Device */ + if (!inv) { double dev[MAX_CHAN], cdev[MAX_CHAN], pcsin[3], devout[MAX_CHAN], pcsout[3]; DCOUNT(co, inn, 0, 0, tres); /* Multi-D counter */ @@ -394,6 +426,74 @@ main( DC_INC(co); } + + /* PCS -> Device -> PCS */ + } else { + double dev[MAX_CHAN], cdev[MAX_CHAN], pcsin[3], devout[MAX_CHAN], pcsout[3]; + DCOUNT(co, 3, 0, 0, tres); /* Multi-D counter */ + + /* Go through the chosen Lab grid */ + DC_INIT(co) + for (; !DC_DONE(co);) { + int n, rv1, rv2; + double sum; + double de; + + pcsin[0] = 100.0 * co[0]/(tres-1.0); + pcsin[1] = (127.0 * 2.0 * co[1]/(tres-1.0)) - 127.0; + pcsin[2] = (127.0 * 2.0 * co[2]/(tres-1.0)) - 127.0; + + /* PCS -> Device */ + if ((rv2 = luo2->lookup(luo2, devout, pcsin)) > 1) + error ("%d, %s",icco->errc,icco->err); + + /* Device to PCS */ + if ((rv2 = luo1->lookup(luo1, pcsout, devout)) > 1) + error ("%d, %s",icco->errc,icco->err); + + /* Delta E */ + if (dovrml) { +// if (fabs(pcsin[0] - 5.0) < 0.1 && dovrml) { + int ix[2]; + + /* Add the verticies */ + ix[0] = wrl->add_vertex(wrl, 0, pcsin); + ix[1] = wrl->add_vertex(wrl, 0, pcsout); + + /* Add the line */ + if (dodecol) { /* Lines with color determined by length */ + double rgb[3]; + DE2RGB(rgb, icmNorm33(pcsin, pcsout)); + wrl->add_col_line(wrl, 0, ix, rgb); + + } else { /* Natural color */ + wrl->add_line(wrl, 0, ix); + } + } + + /* Check the result */ + if (cie2k) + de = icmCIE2K(pcsout, pcsin); + else if (cie94) + de = icmCIE94(pcsout, pcsin); + else + de = icmLabDE(pcsout, pcsin); + + aerr += de; + rerr += de * de; + if (de > merr) + merr = de; + nsamps++; + + if (verb > 1) { + printf("[%f] %f %f %f -> ",de, pcsin[0], pcsin[1], pcsin[2]); + for (n = 0; n < inn; n++) + printf("%f ",devout[n]); + printf("-> %f %f %f\n",pcsout[0], pcsout[1], pcsout[2]); + } + + DC_INC(co); + } } if (dovrml) { wrl->make_lines_vc(wrl, 0, 0.0); |