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

Comparing ray/src/px/pf2.c (file contents):
Revision 2.3 by greg, Fri Oct 2 16:23:20 1992 UTC vs.
Revision 2.4 by greg, Wed Nov 9 15:04:52 1994 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1992 Regents of the University of California */
1 > /* Copyright (c) 1994 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 6 | Line 6 | static char SCCSid[] = "$SunId$ LBL";
6  
7   /*
8   *  pf2.c - routines used by pfilt.
9 *
10 *     10/3/85
9   */
10  
11   #include  <stdio.h>
# Line 41 | Line 39 | extern COLOR  exposure;                /* exposure for frame */
39   #define  AVGLVL         0.5     /* target mean brightness */
40  
41   double  avgbrt;                 /* average picture brightness */
42 + long    npix;                   /* # pixels in average */
43  
44   typedef struct  hotpix {        /* structure for avgbrt pixels */
45          struct hotpix  *next;   /* next in list */
# Line 57 | Line 56 | double sprdfact;               /* computed spread factor */
56   pass1init()                     /* prepare for first pass */
57   {
58          avgbrt = 0.0;
59 +        npix = 0;
60          head = NULL;
61   }
62  
63  
64   pass1default()                  /* for single pass */
65   {
66 <        avgbrt = AVGLVL * xres * yres;
66 >        avgbrt = AVGLVL;
67 >        npix = 1;
68          head = NULL;
69   }
70  
# Line 81 | Line 82 | int  y;
82          
83                  cbrt = bright(scan[x]);
84  
85 <                if (avghot || cbrt < hotlvl)
86 <                        avgbrt += cbrt;
85 >                if (cbrt <= 0)
86 >                        continue;
87  
88 +                if (avghot || cbrt < hotlvl) {
89 +                        avgbrt += cbrt;
90 +                        npix++;
91 +                }
92                  if (npts && cbrt >= hotlvl) {
93                          hp = (HOTPIX *)malloc(sizeof(HOTPIX));
94                          if (hp == NULL) {
# Line 104 | Line 109 | int  y;
109  
110   pass2init()                     /* prepare for final pass */
111   {
112 <        avgbrt /= (double)xres * yres;
113 <
114 <        if (avgbrt <= FTINY) {
110 <                fprintf(stderr, "%s: picture too dark\n", progname);
112 >        if (!npix) {
113 >                fprintf(stderr, "%s: picture too dark or too bright\n",
114 >                                progname);
115                  quit(1);
116          }
117 +        avgbrt /= (double)npix;
118  
119          scalecolor(exposure,  AVGLVL/avgbrt);
120          

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines