--- ray/src/px/pcond.c 1996/10/03 16:52:46 3.1 +++ ray/src/px/pcond.c 1997/01/08 21:40:38 3.7 @@ -1,4 +1,4 @@ -/* Copyright (c) 1996 Regents of the University of California */ +/* Copyright (c) 1997 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -26,6 +26,7 @@ char *progname; /* global argv[0] */ char *infn; /* input file name */ FILE *infp; /* input stream */ +FILE *mapfp = NULL; /* tone-mapping function stream */ VIEW ourview = STDVIEW; /* picture view */ int gotview = 0; /* picture has view */ double pixaspect = 1.0; /* pixel aspect ratio */ @@ -113,6 +114,15 @@ char *argv[]; if (i+1 >= argc) goto userr; ldmin = atof(argv[++i]); break; + case 'm': + if (i+1 >= argc) goto userr; + if ((mapfp = fopen(argv[++i], "w")) == NULL) { + fprintf(stderr, + "%s: cannot open for writing\n", + argv[i]); + exit(1); + } + break; default: goto userr; } @@ -147,9 +157,11 @@ char *argv[]; if (outprims != inprims) fputprims(outprims, stdout); 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}[+-]][-e ev][-p xr yr xg yg xb yb xw yw|-f mbf.cal][-t Ldmax][-b Ldmin] inpic [outpic]\n", + fprintf(stderr, "Usage: %s [-{h|a|v|s|c|l|w}[+-]][-e ev][-p xr yr xg yg xb yb xw yw|-f mbf.cal][-t Ldmax][-b Ldmin][-m mapfile] inpic [outpic]\n", progname); exit(1); #undef bool @@ -278,8 +290,7 @@ mapimage() /* map picture and send to stdout */ fprintf(stderr, "%s: linear scaling factor = %f\n", progname, scalef); #endif - if (scalef < 0.99 | scalef > 1.01) - fputexpos(scalef, stdout); /* write in header */ + fputexpos(inpexp*scalef, stdout); /* record exposure */ if (lumf == cielum) scalef /= WHTEFFICACY; } putchar('\n'); /* complete header */ @@ -346,8 +357,8 @@ fovhist() /* create foveal sampled image and histogr if (lwmin < LMIN) lwmin = LMIN; if (lwmax > LMAX) lwmax = LMAX; /* compute histogram */ - bwmin = Bl(lwmin)*(1. - .01/HISTRES); - bwmax = Bl(lwmax)*(1. + .01/HISTRES); + bwmin = Bl(lwmin); + bwmax = Bl(lwmax); bwavg = 0.; for (y = 0; y < fvyr; y++) for (x = 0; x < fvxr; x++) { @@ -355,9 +366,9 @@ fovhist() /* create foveal sampled image and histogr frandom() > centprob(x,y)) continue; l = plum(fovscan(y)[x]); + if (l < lwmin) continue; + if (l > lwmax) continue; b = Bl(l); - if (b < bwmin) continue; - if (b > bwmax) continue; bwavg += b; bwhc(b)++; histot++; @@ -378,10 +389,14 @@ check2do() /* check histogram to see what isn't worth register int i; /* check for within display range */ - if (!(what2do&DO_LINEAR) && Lb(bwmax)/Lb(bwmin) <= ldmax/ldmin) + l = Lb(bwmax)/Lb(bwmin); + if (l <= ldmax/ldmin) what2do |= DO_LINEAR; + /* determine if veiling significant */ + if (l < 100.) /* heuristic */ + what2do &= ~DO_VEIL; - if (!(what2do & (DO_ACUITY|DO_COLOR|DO_VEIL))) + if (!(what2do & (DO_ACUITY|DO_COLOR))) return; /* find 5th percentile */ sum = histot*0.05 + .5; @@ -390,25 +405,12 @@ check2do() /* check histogram to see what isn't worth break; b = (i+.5)*(bwmax-bwmin)/HISTRES + bwmin; l = Lb(b); -#if 0 /* determine if acuity adj. useful */ if (what2do&DO_ACUITY && hacuity(l) >= (inpres.xr/sqrt(ourview.hn2) + - inpres.yr/sqrt(ourview.vn2))/(2.*180./PI*2.)) + inpres.yr/sqrt(ourview.vn2))/(2.*180./PI)) what2do &= ~DO_ACUITY; -#endif /* color sensitivity loss? */ - if (l >= 6.0) + if (l >= TopMesopic) what2do &= ~DO_COLOR; - if (!(what2do&DO_VEIL)) - return; - /* find 50th percentile (median) */ - sum = histot*0.50 + .5; - for (i = 0; i < HISTRES; i++) - if ((sum -= bwhist[i]) <= 0) - break; - /* determine if veiling significant */ - b = (i+.5)*(bwmax-bwmin)/HISTRES + bwmin; - if ((b-bwmin)/(bwmax-bwmin) >= 0.70) /* heuristic */ - what2do &= ~DO_VEIL; }