--- ray/src/px/pcond.c 1997/02/05 16:08:14 3.10 +++ ray/src/px/pcond.c 1998/10/27 09:08:26 3.13 @@ -12,13 +12,13 @@ static char SCCSid[] = "$SunId$ LBL"; #define LDMAX 100 /* default max. display luminance */ -#define LDMINF 0.01 /* default min. display lum. factor */ +#define LDDYN 32 /* default dynamic range */ int what2do = 0; /* desired adjustments */ double ldmax = LDMAX; /* maximum output luminance */ -double ldmin = 0.; /* minimum output luminance */ -double Bldmin, Bldmax; /* Bl(ldmin) and Bl(ldmax) */ +double lddyn = LDDYN; /* display dynamic range */ +double Bldmin, Bldmax; /* Bl(ldmax/lddyn) and Bl(ldmax) */ char *progname; /* global argv[0] */ @@ -85,6 +85,9 @@ char *argv[]; if (fixfrac > FTINY) what2do |= DO_FIXHIST; else what2do &= ~DO_FIXHIST; break; + case 'I': + bool(DO_PREHIST); + break; case 'l': bool(DO_LINEAR); break; @@ -115,17 +118,17 @@ char *argv[]; if (i+1 >= argc) goto userr; cwarpfile = argv[++i]; break; - case 't': + case 'u': if (i+1 >= argc) goto userr; ldmax = atof(argv[++i]); if (ldmax <= FTINY) goto userr; break; - case 'b': + case 'd': if (i+1 >= argc) goto userr; - ldmin = atof(argv[++i]); + lddyn = atof(argv[++i]); break; - case 'd': + case 'x': if (i+1 >= argc) goto userr; if ((mapfp = fopen(argv[++i], "w")) == NULL) { fprintf(stderr, @@ -137,6 +140,10 @@ char *argv[]; default: goto userr; } + if ((what2do & (DO_FIXHIST|DO_PREHIST)) == (DO_FIXHIST|DO_PREHIST)) { + fprintf(stderr, "%s: only one of -i or -I option\n", progname); + exit(1); + } if ((mbcalfile != NULL) + (cwarpfile != NULL) + (outprims != stdprims) > 1) { fprintf(stderr, @@ -146,14 +153,7 @@ char *argv[]; } if (outprims == stdprims & inprims != stdprims) outprims = inprims; - if (ldmin <= FTINY) - ldmin = ldmax*LDMINF; - else if (ldmin >= ldmax) { - fprintf(stderr, "%s: Ldmin (%f) >= Ldmax (%f)!\n", progname, - ldmin, ldmax); - exit(1); - } - Bldmin = Bl(ldmin); + Bldmin = Bl(ldmax/lddyn); Bldmax = Bl(ldmax); if (i >= argc || i+2 < argc) goto userr; @@ -171,15 +171,18 @@ char *argv[]; printargs(argc, argv, stdout); /* add to output header */ if (mbcalfile == NULL & outprims != stdprims) fputprims(outprims, stdout); - getfovimg(); /* get foveal sample image */ - if (what2do&DO_FIXHIST) /* get fixation history? */ + if ((what2do & (DO_PREHIST|DO_VEIL|DO_ACUITY)) != DO_PREHIST) + getfovimg(); /* get foveal sample image? */ + if (what2do&DO_PREHIST) /* get histogram? */ + gethisto(stdin); + else if (what2do&DO_FIXHIST) /* get fixation history? */ getfixations(stdin); mapimage(); /* map the picture */ if (mapfp != NULL) /* write out basic mapping */ putmapping(mapfp); exit(0); userr: - fprintf(stderr, "Usage: %s [-{h|a|v|s|c|l|w}[+-]][-i ffrac][-e ev][-p xr yr xg yg xb yb xw yw|-f mbf.cal|-m rgb.cwp][-t Ldmax][-b Ldmin][-d mapfile] inpic [outpic]\n", + fprintf(stderr, "Usage: %s [-{h|a|v|s|c|l|w}[+-]][-I|-i ffrac][-e ev][-p xr yr xg yg xb yb xw yw|-f mbf.cal|-m rgb.cwp][-u Ldmax][-d Lddyn][-x mapfile] inpic [outpic]\n", progname); exit(1); #undef bool @@ -205,22 +208,22 @@ char *s; if (!strcmp(fmt,COLRFMT)) lumf = rgblum; else if (!strcmp(fmt,CIEFMT)) lumf = cielum; else lumf = NULL; - return; /* don't echo */ + return(0); /* don't echo */ } if (isprims(s)) { /* get input primaries */ primsval(inprimS, s); inprims= inprimS; - return; /* don't echo */ + return(0); /* don't echo */ } if (isexpos(s)) { /* picture exposure */ inpexp *= exposval(s); - return; /* don't echo */ + return(0); /* don't echo */ } if (isaspect(s)) /* pixel aspect ratio */ pixaspect *= aspectval(s); if (isview(s)) /* image view */ gotview += sscanview(&ourview, s); - fputs(s, stdout); + return(fputs(s, stdout)); }