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

Comparing ray/src/rt/colortab.c (file contents):
Revision 1.13 by greg, Fri Feb 23 10:08:33 1990 UTC vs.
Revision 2.4 by greg, Wed May 5 10:18:47 1993 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1989 Regents of the University of California */
1 > /* Copyright (c) 1992 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 16 | Line 16 | static char SCCSid[] = "$SunId$ LBL";
16   *      distribution is correlated to the last.
17   */
18  
19 < #include "color.h"
19 > #include "standard.h"
20  
21 < #define NULL            0
21 > #include "color.h"
22                                  /* histogram resolution */
23   #define NRED            24
24   #define NGRN            32
# Line 33 | Line 33 | static char SCCSid[] = "$SunId$ LBL";
33                                  (int)(colval(c,p)*256.) : 255 ]
34                                  /* color partition tree */
35   #define CNODE           short
36 < #define set_branch(p,c) ((c)<<2|(p))
36 > #define set_branch(p,c) ((c)<<2|(p))
37   #define set_pval(pv)    ((pv)<<2|3)
38   #define is_branch(cn)   (((cn)&3)!=3)
39   #define is_pval(cn)     (((cn)&3)==3)
# Line 43 | Line 43 | static char SCCSid[] = "$SunId$ LBL";
43                                  /* our color table */
44   static struct tabent {
45          long    sum[3];         /* sum of colors using this entry */
46 <        long    n;              /* number of colors */
47 <        short   ent[3];         /* current table value */
46 >        int     n;              /* number of colors */
47 >        BYTE    ent[3];         /* current table value */
48   }       *clrtab = NULL;
49                                  /* color cube partition */
50   static CNODE    *ctree = NULL;
# Line 53 | Line 53 | static BYTE    clrmap[3][256];
53                                  /* histogram of colors used */
54   static unsigned short   histo[NRED][NGRN][NBLU];
55                                  /* initial color cube boundary */
56 < static int      CLRCUBE[3][2] = {0,NRED,0,NGRN,0,NBLU};
56 > static int      CLRCUBE[3][2] = {{0,NRED},{0,NGRN},{0,NBLU}};
57  
58 + static int      split(), cut();
59  
60 +
61   int
62   new_ctab(ncolors)               /* start new color table with max ncolors */
63   int     ncolors;
# Line 91 | Line 93 | get_pixel(col, set_pixel)      /* get pixel for color */
93   COLOR   col;
94   int     (*set_pixel)();
95   {
96 +        extern char     errmsg[];
97          int     r, g, b;
98          int     cv[3];
99          register CNODE  *tp;
# Line 110 | Line 113 | int    (*set_pixel)();
113                  if (cv[prim(*tp)] < part(*tp))
114                          tp += 1<<h;             /* left branch */
115                  else
116 <                        tp += 1<<(h+1); /* right branch */
116 >                        tp += 1<<(h+1);         /* right branch */
117          h = pval(*tp);
118                                                  /* add to color table */
119          clrtab[h].sum[RED] += r;
# Line 127 | Line 130 | int    (*set_pixel)();
130                          (g-clrtab[h].ent[GRN])*(g-clrtab[h].ent[GRN]) +
131                          (b-clrtab[h].ent[BLU])*(b-clrtab[h].ent[BLU]) > MAXDST2) {
132                  clrtab[h].ent[RED] = r;
133 <                clrtab[h].ent[GRN] = g; /* reassign pixel */
133 >                clrtab[h].ent[GRN] = g; /* reassign pixel */
134                  clrtab[h].ent[BLU] = b;
135   #ifdef DEBUG
136                  sprintf(errmsg, "pixel %d = (%d,%d,%d) (%d refs)\n",
# Line 141 | Line 144 | int    (*set_pixel)();
144  
145  
146   make_gmap(gam)                  /* make gamma correction map */
147 < double  gam;
147 > double  gam;
148   {
146        extern double   pow();
149          register int    i;
150          
151          for (i = 0; i < 256; i++)
152                  clrmap[RED][i] =
153                  clrmap[GRN][i] =
154 <                clrmap[BLU][i] = 256.0 * pow(i/256.0, 1.0/gam);
154 >                clrmap[BLU][i] = 256.0 * pow((i+0.5)/256.0, 1.0/gam);
155   }
156  
157  
# Line 205 | Line 207 | register int   box[3][2];
207   #define c0      r
208          register int    r, g, b;
209          int     pri;
210 <        int     t[HMAX], med;
210 >        long    t[HMAX], med;
211                                          /* find dominant axis */
212          pri = RED;
213          if (box[GRN][1]-box[GRN][0] > box[pri][1]-box[pri][0])

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines