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

Comparing ray/src/px/clrtab.c (file contents):
Revision 2.4 by greg, Fri Feb 5 09:45:40 1993 UTC vs.
Revision 2.5 by greg, Tue Feb 23 15:11:59 1993 UTC

# Line 237 | Line 237 | mktabent(p, box)       /* compute average color for box and
237   int     p;
238   register int    box[3][2];
239   {
240 <        long    sum[3];
241 <        int     r, g, n;
242 <        register int    b, c;
240 >        unsigned long   sum[3];
241 >        unsigned        r, g, n;
242 >        register unsigned       b, c;
243                                                  /* sum pixels in box */
244          n = 0;
245          sum[RED] = sum[GRN] = sum[BLU] = 0;
# Line 254 | Line 254 | register int   box[3][2];
254                      }
255                      histo[r][g][b] = p;         /* assign pixel */
256                  }
257 +        if (n >= (1<<23)/HMAX) {                /* avoid overflow */
258 +                sum[RED] /= n;
259 +                sum[GRN] /= n;
260 +                sum[BLU] /= n;
261 +                n = 1;
262 +        }
263          if (n) {                                /* compute average */
264                  clrtab[p][RED] = sum[RED]*256/NRED/n;
265                  clrtab[p][GRN] = sum[GRN]*256/NGRN/n;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines