From c07d0c2d2f6f7b0eb6e92cc6204bf05037957e82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Mon, 1 Sep 2014 15:43:52 +0200 Subject: Imported Upstream version 1.6.3 --- profile/colprof.c | 96 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 63 insertions(+), 33 deletions(-) (limited to 'profile/colprof.c') diff --git a/profile/colprof.c b/profile/colprof.c index 99e02cf..b80f13c 100644 --- a/profile/colprof.c +++ b/profile/colprof.c @@ -59,13 +59,15 @@ #define DEFAVGDEV 0.5 /* Default average deviation percentage */ /* This equates to a uniform added error of +/- 1% */ +#define DEMPH_DEFAULT 1.0 /* Default dark region emphasis == none */ + /* Flags used: ABCDEFGHIJKLMNOPQRSTUVWXYZ upper . .. . ... .. .... . - lower .... .. . .. ......... . + lower .... .. . .. ......... */ @@ -94,7 +96,6 @@ void usage(char *diag, ...) { // fprintf(stderr," -q fmsu Speed - Fast, Medium (def), Slow, Ultra Slow\n"); fprintf(stderr," -b [lmhun] Low quality B2A table - or specific B2A quality or none for input device\n"); // fprintf(stderr," -b [fmsun] B2A Speed - Fast, Medium, Slow, Ultra Slow, None, same as -q (def)\n"); - fprintf(stderr," -y Verify A2B profile\n"); fprintf(stderr," -ni Don't create input (Device) shaper curves\n"); fprintf(stderr," -np Don't create input (Device) grid position curves\n"); fprintf(stderr," -no Don't create output (PCS) shaper curves\n"); @@ -121,6 +122,7 @@ void usage(char *diag, ...) { fprintf(stderr," -uc If input profile, clip cLUT values above WP\n"); fprintf(stderr," -U scale If input profile, scale media white point by scale\n"); fprintf(stderr," -R Restrict white <= 1.0, black and primaries to be +ve\n"); + fprintf(stderr," -V demphasis Degree of dark region cLUT grid emphasis 1.0-4.0 (default %.2f = none)\n",DEMPH_DEFAULT); fprintf(stderr," -f [illum] Use Fluorescent Whitening Agent compensation [opt. simulated inst. illum.:\n"); fprintf(stderr," M0, M1, M2, A, C, D50 (def.), D50M2, D65, F5, F8, F10 or file.sp]\n"); fprintf(stderr," -i illum Choose illuminant for computation of CIE XYZ from spectral data & FWA:\n"); @@ -172,7 +174,7 @@ int main(int argc, char *argv[]) { int verb = 0; int iquality = 1; /* A2B quality */ int oquality = -1; /* B2A quality same as A2B */ - int verify = 0; + int verify = 0; /* Not used anymore */ int noisluts = 0; /* No input shaper luts */ int noipluts = 0; /* No input position luts */ int nooluts = 0; /* No output shaper luts */ @@ -183,6 +185,7 @@ int main(int argc, char *argv[]) { int autowpsc = 0; /* Auto scale the WP to prevent clipping above WP patch */ int clipovwp = 0; /* Clip cLUT values above WP */ int clipprims = 0; /* Clip white, black and primaries */ + double demph = 0.0; /* Emphasise dark region grid resolution in cLUT */ double iwpscale = -1.0; /* Input white point scale factor */ int doinextrap = 1; /* Sythesize extra sample points for input device cLUT */ int doinb2a = 1; /* Create an input device B2A table */ @@ -238,7 +241,8 @@ int main(int argc, char *argv[]) { ivc_p.Yb = -1.0; ivc_p.Lv = -1.0; ivc_p.Yf = -1.0; - ivc_p.Fxyz[0] = -1.0; ivc_p.Fxyz[1] = -1.0; ivc_p.Fxyz[2] = -1.0; + ivc_p.Yg = -1.0; + ivc_p.Gxyz[0] = -1.0; ivc_p.Gxyz[1] = -1.0; ivc_p.Gxyz[2] = -1.0; ovc_p.Ev = -1; ovc_p.Wxyz[0] = -1.0; ovc_p.Wxyz[1] = -1.0; ovc_p.Wxyz[2] = -1.0; @@ -246,7 +250,8 @@ int main(int argc, char *argv[]) { ovc_p.Yb = -1.0; ovc_p.Lv = -1.0; ovc_p.Yf = -1.0; - ovc_p.Fxyz[0] = -1.0; ovc_p.Fxyz[1] = -1.0; ovc_p.Fxyz[2] = -1.0; + ovc_p.Yg = -1.0; + ovc_p.Gxyz[0] = -1.0; ovc_p.Gxyz[1] = -1.0; ovc_p.Gxyz[2] = -1.0; xicc_enum_gmapintent(&pgmi, icxPerceptualGMIntent, NULL); xicc_enum_gmapintent(&sgmi, icxSaturationGMIntent, NULL); @@ -276,7 +281,7 @@ int main(int argc, char *argv[]) { if (argv[fa][1] == '?') usage("Usage requested"); - else if (argv[fa][1] == 'v' || argv[fa][1] == 'V') + else if (argv[fa][1] == 'v') verb = 1; /* Manufacturer description string */ @@ -361,7 +366,7 @@ int main(int argc, char *argv[]) { } /* Quality */ - else if (argv[fa][1] == 'q' || argv[fa][1] == 'Q') { + else if (argv[fa][1] == 'q') { fa = nfa; // if (na == NULL) usage("Expect argument to quality flag -q"); if (na == NULL) usage("Expect argument to speed flag -q"); @@ -428,11 +433,8 @@ int main(int argc, char *argv[]) { doinb2a = 0; } - else if (argv[fa][1] == 'y' || argv[fa][1] == 'Y') - verify = 1; - /* Disable input or output luts */ - else if (argv[fa][1] == 'n' || argv[fa][1] == 'N') { + else if (argv[fa][1] == 'n') { fa = nfa; if (na == NULL) { /* Backwards compatible */ nooluts = 1; @@ -468,7 +470,7 @@ int main(int argc, char *argv[]) { fa = nfa; if (na == NULL) usage("Expected argument to input white point scale flag -U"); iwpscale = atof(na); - if (iwpscale < 0.0 || iwpscale > 100.0) + if (iwpscale < 0.0 || iwpscale > 200.0) usage("Argument '%s' to flag -U out of range",na); } /* Clip primaries */ @@ -476,8 +478,18 @@ int main(int argc, char *argv[]) { clipprims = 1; } + /* Degree of dark region emphasis */ + else if (argv[fa][1] == 'V') { + if (na == NULL) usage(0,"Expected argument to dark emphasis flag -V"); + demph = atof(na); + if (demph < 1.0 || demph > 3.0) + usage("Dark weighting argument %f to '-V' is out of range",demph); + fa = nfa; + } + /* Inking rule */ - else if (argv[fa][1] == 'k' || argv[fa][1] == 'K') { + else if (argv[fa][1] == 'k' + || argv[fa][1] == 'K') { fa = nfa; if (na == NULL) usage("Expect argument to inking flag -k"); if (argv[fa][1] == 'k') @@ -544,7 +556,7 @@ int main(int argc, char *argv[]) { } /* Algorithm type */ - else if (argv[fa][1] == 'a' || argv[fa][1] == 'A') { + else if (argv[fa][1] == 'a') { fa = nfa; if (na == NULL) usage("Expect argument to algorithm flag -a"); switch (na[0]) { @@ -713,7 +725,8 @@ int main(int argc, char *argv[]) { } /* Percetual Source Gamut and Perceptual/Saturation Gamut Maping mode enable */ - else if (argv[fa][1] == 's' || argv[fa][1] == 'S') { + else if (argv[fa][1] == 's' + || argv[fa][1] == 'S') { if (argv[fa][1] == 'S') sepsat = 1; if (na == NULL) @@ -724,7 +737,7 @@ int main(int argc, char *argv[]) { } /* Source image gamut */ - else if (argv[fa][1] == 'g' || argv[fa][1] == 'G') { + else if (argv[fa][1] == 'g') { if (na == NULL) usage("Unrecognised argument to source image gamut flag -g",argv[fa][1]); fa = nfa; @@ -771,7 +784,8 @@ int main(int argc, char *argv[]) { } /* Viewing conditions */ - else if (argv[fa][1] == 'c' || argv[fa][1] == 'd') { + else if (argv[fa][1] == 'c' + || argv[fa][1] == 'd') { icxViewCond *vc; if (argv[fa][1] == 'c') { @@ -781,7 +795,7 @@ int main(int argc, char *argv[]) { } fa = nfa; - if (na == NULL) usage("Viewing conditions flag (-c) needs an argument"); + if (na == NULL) usage("Viewing conditions flag (-%c) needs an argument",argv[fa][1]); if (na[1] != ':') { if (vc == &ivc_p) { if ((ivc_e = xicc_enum_viewcond(NULL, NULL, -2, na, 1, NULL)) == -999) @@ -792,7 +806,7 @@ int main(int argc, char *argv[]) { } } else if (na[0] == 's' || na[0] == 'S') { if (na[1] != ':') - usage("Viewing conditions (-cs) missing ':'"); + usage("Viewing conditions (-%cs) missing ':'",argv[fa][1]); if (na[2] == 'n' || na[2] == 'N') { vc->Ev = vc_none; /* Automatic */ } else if (na[2] == 'a' || na[2] == 'A') { @@ -804,7 +818,7 @@ int main(int argc, char *argv[]) { } else if (na[2] == 'c' || na[2] == 'C') { vc->Ev = vc_cut_sheet; } else - usage("Viewing condition (-c) unrecognised surround '%c'",na[2]); + usage("Viewing condition (-%c) unrecognised surround '%c'",argv[fa][1],na[2]); } else if (na[0] == 'w' || na[0] == 'W') { double x, y, z; if (sscanf(na+1,":%lf:%lf:%lf",&x,&y,&z) == 3) { @@ -812,31 +826,35 @@ int main(int argc, char *argv[]) { } else if (sscanf(na+1,":%lf:%lf",&x,&y) == 2) { vc->Wxyz[0] = x; vc->Wxyz[1] = y; } else - usage("Viewing condition (-cw) unrecognised white point '%s'",na+1); + usage("Viewing condition (-%cw) unrecognised white point '%s'",argv[fa][1],na+1); } else if (na[0] == 'a' || na[0] == 'A') { if (na[1] != ':') - usage("Viewing conditions (-ca) missing ':'"); + usage("Viewing conditions (-%ca) missing ':'",argv[fa][1]); vc->La = atof(na+2); } else if (na[0] == 'b' || na[0] == 'B') { if (na[1] != ':') - usage("Viewing conditions (-cb) missing ':'"); + usage("Viewing conditions (-%cb) missing ':'",argv[fa][1]); vc->Yb = atof(na+2)/100.0; } else if (na[0] == 'l' || na[0] == 'L') { if (na[1] != ':') - usage("Viewing conditions (-[cd]l) missing ':'"); + usage("Viewing conditions (-%cl) missing ':'",argv[fa][1]); vc->Lv = atof(na+2); } else if (na[0] == 'f' || na[0] == 'F') { + if (na[1] != ':') + usage("Viewing conditions (-%cf) missing ':'",argv[fa][1]); + vc->Yf = atof(na+2); + } else if (na[0] == 'g' || na[0] == 'G') { double x, y, z; if (sscanf(na+1,":%lf:%lf:%lf",&x,&y,&z) == 3) { - vc->Fxyz[0] = x; vc->Fxyz[1] = y; vc->Fxyz[2] = z; + vc->Gxyz[0] = x; vc->Gxyz[1] = y; vc->Gxyz[2] = z; } else if (sscanf(na+1,":%lf:%lf",&x,&y) == 2) { - vc->Fxyz[0] = x; vc->Fxyz[1] = y; + vc->Gxyz[0] = x; vc->Gxyz[1] = y; } else if (sscanf(na+1,":%lf",&x) == 1) { - vc->Yf = x/100.0; + vc->Yg = x/100.0; } else - usage("Viewing condition (-cf) unrecognised flare '%s'",na+1); + usage("Viewing condition (-%cg) unrecognised flare '%s'",argv[fa][1],na+1); } else - usage("Viewing condition (-c) unrecognised sub flag '%c'",na[0]); + usage("Viewing condition (-%c) unrecognised sub flag '%c'",argv[fa][1],na[0]); } /* Gammut mapping diagnostic plots */ @@ -929,6 +947,18 @@ int main(int argc, char *argv[]) { error ("Requested spectral interpretation when data not available"); } + /* If not set in arguments, set default demph from .ti1 or default none */ + if (demph == 0.0) { + if ((ti = icg->find_kword(icg, 0, "DARK_REGION_EMPHASIS")) >= 0) { + demph = atof(icg->t[0].kdata[ti]); + demph = pow(demph, 0.7); /* Reduce intensity */ + if (verb) + printf("Dark emphasis factor %f from targen\n",demph); + } else { + demph = DEMPH_DEFAULT; + } + } + /* read the device class, and call function to create profile. */ if ((ti = icg->find_kword(icg, 0, "DEVICE_CLASS")) < 0) error ("Input file doesn't contain keyword DEVICE_CLASS"); @@ -1045,9 +1075,9 @@ int main(int argc, char *argv[]) { make_output_icc(ptype, 0, iccver, verb, iquality, oquality, noisluts, noipluts, nooluts, nocied, noptop, nostos, - gamdiag, verify, clipprims, &ink, inname, outname, icg, + gamdiag, verify, clipprims, iwpscale, &ink, inname, outname, icg, spec, tillum, &cust_tillum, illum, &cust_illum, observ, fwacomp, - smooth, avgdev, + smooth, avgdev, 1.0, ipname[0] != '\000' ? ipname : NULL, sgname[0] != '\000' ? sgname : NULL, absnames, @@ -1083,9 +1113,9 @@ int main(int argc, char *argv[]) { /* If a source gamut is provided for a Display, then a V2.4.0 profile will be created */ make_output_icc(ptype, mtxtoo, iccver, verb, iquality, oquality, noisluts, noipluts, nooluts, nocied, noptop, nostos, - gamdiag, verify, clipprims, NULL, inname, outname, icg, + gamdiag, verify, clipprims, iwpscale, NULL, inname, outname, icg, spec, icxIT_none, NULL, illum, &cust_illum, observ, 0, - smooth, avgdev, + smooth, avgdev, demph, ipname[0] != '\000' ? ipname : NULL, sgname[0] != '\000' ? sgname : NULL, absnames, -- cgit v1.2.3