summaryrefslogtreecommitdiff
path: root/xicc/iccgamut.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2017-12-01 10:32:14 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2017-12-01 10:32:14 +0100
commit4097e27114d227692d53c5d28487e12a3833cd24 (patch)
treed5c2a62c4db97de94f92150340612c64d3997669 /xicc/iccgamut.c
parentf8a0a4e1c775a90c313cb83201eec4cea4e9a7da (diff)
parent5514d94483c98e3320b202b1bb882023a7d12027 (diff)
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'xicc/iccgamut.c')
-rwxr-xr-x[-rw-r--r--]xicc/iccgamut.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/xicc/iccgamut.c b/xicc/iccgamut.c
index ecbab7f..a7f11fe 100644..100755
--- a/xicc/iccgamut.c
+++ b/xicc/iccgamut.c
@@ -88,6 +88,10 @@ void usage(char *diag) {
fprintf(stderr," g:glare Flare light %% of ambient (default %d)\n",XICC_DEFAULT_GLARE);
fprintf(stderr," g:X:Y:Z Flare color as XYZ (default media white, Abs: D50)\n");
fprintf(stderr," g:x:y Flare color as x, y\n");
+ fprintf(stderr," h:hkscale Helmholtz-Kohlrausch effect scale factor (default 1.0)\n");
+ fprintf(stderr," m:mtaf Mid-tone partial adaptation factor (default 0.0)\n");
+ fprintf(stderr," m:X:Y:Z Mid-tone Adaptation white as XYZ (default D50)\n");
+ fprintf(stderr," m:x:y Mid-tone Adaptation white as x, y\n");
fprintf(stderr," -x pcent Expand/compress gamut cylindrically by percent\n");
fprintf(stderr," -s Create special cube surface topology plot\n");
fprintf(stderr,"\n");
@@ -126,6 +130,9 @@ main(int argc, char *argv[]) {
double vc_g = -1.0; /* Glare % overide */
double vc_gXYZ[3] = {-1.0, -1.0, -1.0}; /* Glare color override in XYZ */
double vc_gxy[2] = {-1.0, -1.0}; /* Glare color override in x,y */
+ double vc_hkscale = -1.0; /* HK scaling factor */
+ double vc_mtaf = -1.0; /* Mid tone partial adapation factor from Wxyz to Wxyz2 */
+ double vc_Wxyz2[3] = {-1.0, -1.0, -1.0}; /* Adapted white override in XYZ */
double expand = 1.0; /* Expand gamut cylindrically */
icxLuBase *luo;
@@ -362,6 +369,20 @@ main(int argc, char *argv[]) {
vc_g = x;
} else
usage("Unrecognised parameters after -cg");
+ } else if (na[0] == 'h' || na[0] == 'H') {
+ if (na[1] != ':')
+ usage("Unrecognised parameters after -ch");
+ vc_hkscale = atof(na+2);
+ } else if (na[0] == 'm' || na[0] == 'M') {
+ double x, y, z;
+ if (sscanf(na+1,":%lf:%lf:%lf",&x,&y,&z) == 3) {
+ vc_Wxyz2[0] = x; vc_Wxyz2[1] = y; vc_Wxyz2[2] = z;
+ } else if (sscanf(na+1,":%lf:%lf",&x,&y) == 2) {
+ vc_Wxyz2[0] = x; vc_Wxyz2[1] = y; vc_Wxyz2[2] = -1;
+ } else if (sscanf(na+1,":%lf",&x) == 1) {
+ vc_mtaf = x;
+ } else
+ usage("Unrecognised parameters after -cm");
} else
usage("Unrecognised parameters after -c");
}
@@ -467,6 +488,23 @@ main(int argc, char *argv[]) {
vc.Gxyz[0] = x/y * vc.Gxyz[1];
vc.Gxyz[2] = z/y * vc.Gxyz[1];
}
+ if (vc_hkscale >= 0.0)
+ vc.hkscale = vc_hkscale;
+ if (vc_mtaf >= 0.0)
+ vc.mtaf = vc_mtaf;
+ if (vc_Wxyz2[0] >= 0.0 && vc_Wxyz2[1] > 0.0 && vc_Wxyz2[2] >= 0.0) {
+ /* Normalise XYZ */
+ vc.Wxyz2[0] = vc_Wxyz2[0]/vc_Wxyz2[1] * vc.Wxyz2[1];
+ vc.Wxyz2[2] = vc_Wxyz2[2]/vc_Wxyz2[1] * vc.Wxyz2[1];
+ }
+ if (vc_Wxyz2[0] >= 0.0 && vc_Wxyz2[1] >= 0.0 && vc_Wxyz2[2] < 0.0) {
+ /* Convert Yxy to XYZ */
+ double x = vc_Wxyz2[0];
+ double y = vc_Wxyz2[1]; /* If Y == 1.0, then X+Y+Z = 1/y */
+ double z = 1.0 - x - y;
+ vc.Wxyz2[0] = x/y * vc.Wxyz2[1];
+ vc.Wxyz2[2] = z/y * vc.Wxyz2[1];
+ }
fl |= ICX_CLIP_NEAREST; /* Don't setup rev uncessarily */