| 1 |
< |
/* Copyright (c) 1996 Regents of the University of California */ |
| 1 |
> |
/* Copyright (c) 1997 Regents of the University of California */ |
| 2 |
|
|
| 3 |
|
#ifndef lint |
| 4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
| 26 |
|
|
| 27 |
|
char *infn; /* input file name */ |
| 28 |
|
FILE *infp; /* input stream */ |
| 29 |
+ |
FILE *mapfp = NULL; /* tone-mapping function stream */ |
| 30 |
|
VIEW ourview = STDVIEW; /* picture view */ |
| 31 |
|
int gotview = 0; /* picture has view */ |
| 32 |
|
double pixaspect = 1.0; /* pixel aspect ratio */ |
| 114 |
|
if (i+1 >= argc) goto userr; |
| 115 |
|
ldmin = atof(argv[++i]); |
| 116 |
|
break; |
| 117 |
+ |
case 'm': |
| 118 |
+ |
if (i+1 >= argc) goto userr; |
| 119 |
+ |
if ((mapfp = fopen(argv[++i], "w")) == NULL) { |
| 120 |
+ |
fprintf(stderr, |
| 121 |
+ |
"%s: cannot open for writing\n", |
| 122 |
+ |
argv[i]); |
| 123 |
+ |
exit(1); |
| 124 |
+ |
} |
| 125 |
+ |
break; |
| 126 |
|
default: |
| 127 |
|
goto userr; |
| 128 |
|
} |
| 157 |
|
if (outprims != inprims) |
| 158 |
|
fputprims(outprims, stdout); |
| 159 |
|
mapimage(); /* map the picture */ |
| 160 |
+ |
if (mapfp != NULL) /* write out basic mapping */ |
| 161 |
+ |
putmapping(mapfp); |
| 162 |
|
exit(0); |
| 163 |
|
userr: |
| 164 |
< |
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", |
| 164 |
> |
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", |
| 165 |
|
progname); |
| 166 |
|
exit(1); |
| 167 |
|
#undef bool |
| 357 |
|
if (lwmin < LMIN) lwmin = LMIN; |
| 358 |
|
if (lwmax > LMAX) lwmax = LMAX; |
| 359 |
|
/* compute histogram */ |
| 360 |
< |
bwmin = Bl(lwmin)*(1. - .01/HISTRES); |
| 361 |
< |
bwmax = Bl(lwmax)*(1. + .01/HISTRES); |
| 360 |
> |
bwmin = Bl(lwmin); |
| 361 |
> |
bwmax = Bl(lwmax); |
| 362 |
|
bwavg = 0.; |
| 363 |
|
for (y = 0; y < fvyr; y++) |
| 364 |
|
for (x = 0; x < fvxr; x++) { |
| 366 |
|
frandom() > centprob(x,y)) |
| 367 |
|
continue; |
| 368 |
|
l = plum(fovscan(y)[x]); |
| 369 |
+ |
if (l < lwmin) continue; |
| 370 |
+ |
if (l > lwmax) continue; |
| 371 |
|
b = Bl(l); |
| 358 |
– |
if (b < bwmin) continue; |
| 359 |
– |
if (b > bwmax) continue; |
| 372 |
|
bwavg += b; |
| 373 |
|
bwhc(b)++; |
| 374 |
|
histot++; |
| 408 |
|
/* determine if acuity adj. useful */ |
| 409 |
|
if (what2do&DO_ACUITY && |
| 410 |
|
hacuity(l) >= (inpres.xr/sqrt(ourview.hn2) + |
| 411 |
< |
inpres.yr/sqrt(ourview.vn2))/(2.*180./PI*2.)) |
| 411 |
> |
inpres.yr/sqrt(ourview.vn2))/(2.*180./PI)) |
| 412 |
|
what2do &= ~DO_ACUITY; |
| 413 |
|
/* color sensitivity loss? */ |
| 414 |
< |
if (l >= 6.0) |
| 414 |
> |
if (l >= TopMesopic) |
| 415 |
|
what2do &= ~DO_COLOR; |
| 416 |
|
} |