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.9 by greg, Mon Oct 16 13:43:26 1989 UTC vs.
Revision 1.12 by greg, Fri Feb 9 09:14:52 1990 UTC

# Line 80 | Line 80 | int    ncolors;
80                                  /* partition color space */
81          cut(ctree, 0, CLRCUBE, 0, ncolors);
82                                  /* clear histogram */
83 <        bzero(histo, sizeof(histo));
83 >        bzero((char *)histo, sizeof(histo));
84                                  /* return number of colors used */
85          return(ncolors);
86   }
# Line 93 | Line 93 | int    (*set_pixel)();
93   {
94          int     r, g, b;
95          int     cv[3];
96 <        register union { CNODE *t; struct tabent *e; }  p;
96 >        register CNODE  *tp;
97          register int    h;
98                                                  /* map color */
99          r = map_col(col,RED);
# Line 106 | Line 106 | int    (*set_pixel)();
106                                                  /* add to histogram */
107          histo[cv[RED]][cv[GRN]][cv[BLU]]++;
108                                                  /* find pixel in tree */
109 <        for (p.t = ctree, h = 0; is_branch(*p.t); h++)
110 <                if (cv[prim(*p.t)] < part(*p.t))
111 <                        p.t += 1<<h;            /* left branch */
109 >        for (tp = ctree, h = 0; is_branch(*tp); h++)
110 >                if (cv[prim(*tp)] < part(*tp))
111 >                        tp += 1<<h;             /* left branch */
112                  else
113 <                        p.t += 1<<(h+1);        /* right branch */
114 <        h = pval(*p.t);
113 >                        tp += 1<<(h+1); /* right branch */
114 >        h = pval(*tp);
115                                                  /* add to color table */
116 <        p.e = clrtab + h;
117 <                                        /* add to sum */
118 <        p.e->sum[RED] += r;
119 <        p.e->sum[GRN] += g;
120 <        p.e->sum[BLU] += b;
121 <        p.e->n++;
116 >        clrtab[h].sum[RED] += r;
117 >        clrtab[h].sum[GRN] += g;
118 >        clrtab[h].sum[BLU] += b;
119 >        clrtab[h].n++;
120                                          /* recompute average */
121 <        r = p.e->sum[RED] / p.e->n;
122 <        g = p.e->sum[GRN] / p.e->n;
123 <        b = p.e->sum[BLU] / p.e->n;
121 >        r = clrtab[h].sum[RED] / clrtab[h].n;
122 >        g = clrtab[h].sum[GRN] / clrtab[h].n;
123 >        b = clrtab[h].sum[BLU] / clrtab[h].n;
124                                          /* check for movement */
125 <        if (p.e->n == 1 ||
126 <                        (r-p.e->ent[RED])*(r-p.e->ent[RED]) +
127 <                        (g-p.e->ent[GRN])*(g-p.e->ent[GRN]) +
128 <                        (b-p.e->ent[BLU])*(b-p.e->ent[BLU]) > MAXDST2) {
129 <                p.e->ent[RED] = r;
130 <                p.e->ent[GRN] = g;      /* reassign pixel */
131 <                p.e->ent[BLU] = b;
132 < #ifdef notdef
133 <                printf("pixel %d = (%d,%d,%d) (%d refs)\n",
134 <                                h, r, g, b, p.e->n);
125 >        if (clrtab[h].n == 1 ||
126 >                        (r-clrtab[h].ent[RED])*(r-clrtab[h].ent[RED]) +
127 >                        (g-clrtab[h].ent[GRN])*(g-clrtab[h].ent[GRN]) +
128 >                        (b-clrtab[h].ent[BLU])*(b-clrtab[h].ent[BLU]) > MAXDST2) {
129 >                clrtab[h].ent[RED] = r;
130 >                clrtab[h].ent[GRN] = g; /* reassign pixel */
131 >                clrtab[h].ent[BLU] = b;
132 > #ifdef DEBUG
133 >                sprintf(errmsg, "pixel %d = (%d,%d,%d) (%d refs)\n",
134 >                                h, r, g, b, clrtab[h].n);
135 >                eputs(errmsg);
136   #endif
137                  (*set_pixel)(h, r, g, b);
138          }
# Line 157 | Line 156 | double  gam;
156   set_cmap(rmap, gmap, bmap)      /* set custom color correction map */
157   BYTE    *rmap, *gmap, *bmap;
158   {
159 <        bcopy(rmap, clrmap[RED], 256);
160 <        bcopy(gmap, clrmap[GRN], 256);
161 <        bcopy(bmap, clrmap[BLU], 256);
159 >        bcopy((char *)rmap, (char *)clrmap[RED], 256);
160 >        bcopy((char *)gmap, (char *)clrmap[GRN], 256);
161 >        bcopy((char *)bmap, (char *)clrmap[BLU], 256);
162   }
163  
164  
# Line 178 | Line 177 | int    c0, c1;
177          }
178                                          /* split box */
179          *tree = split(box);
180 <        bcopy(box, kb, sizeof(kb));
180 >        bcopy((char *)box, (char *)kb, sizeof(kb));
181                                                  /* do left (lesser) branch */
182          kb[prim(*tree)][1] = part(*tree);
183          cut(tree+(1<<level), level+1, kb, c0, (c0+c1)>>1);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines