ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/pcond.c
(Generate patch)

Comparing ray/src/px/pcond.c (file contents):
Revision 3.11 by greg, Wed Mar 19 13:04:09 1997 UTC vs.
Revision 3.14 by greg, Sat Feb 22 02:07:27 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1997 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Condition Radiance picture for display/output
6 + *  Added white-balance adjustment 10/01 (GW).
7   */
8  
9   #include "pcond.h"
# Line 32 | Line 30 | double fixfrac = 0.;                   /* histogram share due to fixat
30   RESOLU  inpres;                         /* input picture resolution */
31  
32   COLOR   *fovimg;                        /* foveal (1 degree) averaged image */
33 < short   fvxr, fvyr;                     /* foveal image resolution */
33 > int     fvxr, fvyr;                     /* foveal image resolution */
34 > float   *crfimg;                        /* contrast reduction factors */
35   short   (*fixlst)[2];                   /* fixation history list */
36   int     nfixations;                     /* number of fixation points */
37 < float   bwhist[HISTRES];                /* luminance histogram */
37 > double  bwhist[HISTRES];                /* luminance histogram */
38   double  histot;                         /* total count of histogram */
39   double  bwmin, bwmax;                   /* histogram limits */
40   double  bwavg;                          /* mean brightness */
# Line 85 | Line 84 | char   *argv[];
84                          if (fixfrac > FTINY) what2do |= DO_FIXHIST;
85                          else what2do &= ~DO_FIXHIST;
86                          break;
87 +                case 'I':
88 +                        bool(DO_PREHIST);
89 +                        break;
90                  case 'l':
91                          bool(DO_LINEAR);
92                          break;
# Line 137 | Line 139 | char   *argv[];
139                  default:
140                          goto userr;
141                  }
142 +        if ((what2do & (DO_FIXHIST|DO_PREHIST)) == (DO_FIXHIST|DO_PREHIST)) {
143 +                fprintf(stderr, "%s: only one of -i or -I option\n", progname);
144 +                exit(1);
145 +        }
146          if ((mbcalfile != NULL) + (cwarpfile != NULL) +
147                          (outprims != stdprims) > 1) {
148                  fprintf(stderr,
# Line 164 | Line 170 | char   *argv[];
170          printargs(argc, argv, stdout);  /* add to output header */
171          if (mbcalfile == NULL & outprims != stdprims)
172                  fputprims(outprims, stdout);
173 <        getfovimg();                    /* get foveal sample image */
174 <        if (what2do&DO_FIXHIST)         /* get fixation history? */
173 >        if ((what2do & (DO_PREHIST|DO_VEIL|DO_ACUITY)) != DO_PREHIST)
174 >                getfovimg();            /* get foveal sample image? */
175 >        if (what2do&DO_PREHIST)         /* get histogram? */
176 >                gethisto(stdin);
177 >        else if (what2do&DO_FIXHIST)    /* get fixation history? */
178                  getfixations(stdin);
179          mapimage();                     /* map the picture */
180          if (mapfp != NULL)              /* write out basic mapping */
181                  putmapping(mapfp);
182          exit(0);
183   userr:
184 <        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][-u Ldmax][-d Lddyn][-x mapfile] inpic [outpic]\n",
184 >        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",
185                          progname);
186          exit(1);
187   #undef bool
# Line 198 | Line 207 | char   *s;
207                  if (!strcmp(fmt,COLRFMT)) lumf = rgblum;
208                  else if (!strcmp(fmt,CIEFMT)) lumf = cielum;
209                  else lumf = NULL;
210 <                return;                 /* don't echo */
210 >                return(0);              /* don't echo */
211          }
212          if (isprims(s)) {               /* get input primaries */
213                  primsval(inprimS, s);
214                  inprims= inprimS;
215 <                return;                 /* don't echo */
215 >                return(0);              /* don't echo */
216          }
217          if (isexpos(s)) {               /* picture exposure */
218                  inpexp *= exposval(s);
219 <                return;                 /* don't echo */
219 >                return(0);              /* don't echo */
220          }
221          if (isaspect(s))                /* pixel aspect ratio */
222                  pixaspect *= aspectval(s);
223          if (isview(s))                  /* image view */
224                  gotview += sscanview(&ourview, s);
225 <        fputs(s, stdout);
225 >        return(fputs(s, stdout));
226   }
227  
228  
# Line 228 | Line 237 | getahead()                     /* load picture header */
237                  exit(1);
238          }
239          if (lumf == rgblum)
240 <                comprgb2xyzmat(inrgb2xyz, inprims);
240 >                comprgb2xyzWBmat(inrgb2xyz, inprims);
241          else if (mbcalfile != NULL) {
242                  fprintf(stderr, "%s: macbethcal only works with RGB pictures\n",
243                                  progname);
# Line 262 | Line 271 | mapimage()                             /* map picture and send to stdout */
271          comphist();                     /* generate adaptation histogram */
272          check2do();                     /* modify what2do flags */
273          if (what2do&DO_VEIL)
274 <                compveil();
275 <        if (!(what2do&DO_LINEAR) && mkbrmap() < 0)      /* make tone map */
276 <                what2do |= DO_LINEAR;   /* failed! -- use linear scaling */
274 >                compveil();             /* compute veil image */
275 >        if (!(what2do&DO_LINEAR))
276 >                if (mkbrmap() < 0)      /* make tone map */
277 >                        what2do |= DO_LINEAR;   /* failed! -- use linear */
278 > #if ADJ_VEIL
279 >                else if (what2do&DO_VEIL)
280 >                        adjveil();      /* else adjust veil image */
281 > #endif
282          if (what2do&DO_LINEAR) {
283                  if (scalef <= FTINY) {
284                          if (what2do&DO_HSENS)
# Line 301 | Line 315 | getfovimg()                    /* load foveal sampled image */
315          if (fvxr < 2) fvxr = 2;
316          fvyr = sqrt(ourview.vn2)/FOVDIA + 0.5;
317          if (fvyr < 2) fvyr = 2;
318 <        if (!(inpres.or & YMAJOR)) {            /* picture is rotated? */
318 >        if (!(inpres.rt & YMAJOR)) {            /* picture is rotated? */
319                  y = fvyr;
320                  fvyr = fvxr;
321                  fvxr = y;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines