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.7 by greg, Thu Jun 10 15:45:18 1993 UTC

# Line 181 | Line 181 | register int   box[3][2];
181   #define c0      r
182          register int    r, g, b;
183          int     pri;
184 <        int     t[HMAX], med;
184 >        long    t[HMAX], med;
185                                          /* find dominant axis */
186          pri = RED;
187          if (box[GRN][1]-box[GRN][0] > box[pri][1]-box[pri][0])
# 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;
242 >        unsigned long   n;
243 >        register unsigned       b, c;
244                                                  /* sum pixels in box */
245          n = 0;
246          sum[RED] = sum[GRN] = sum[BLU] = 0;
# Line 254 | Line 255 | register int   box[3][2];
255                      }
256                      histo[r][g][b] = p;         /* assign pixel */
257                  }
258 +        if (n >= (1L<<23)/HMAX) {               /* avoid overflow */
259 +                sum[RED] /= n;
260 +                sum[GRN] /= n;
261 +                sum[BLU] /= n;
262 +                n = 1;
263 +        }
264          if (n) {                                /* compute average */
265                  clrtab[p][RED] = sum[RED]*256/NRED/n;
266                  clrtab[p][GRN] = sum[GRN]*256/NGRN/n;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines