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.10 by greg, Tue Jan 16 16:00:00 1990 UTC

# 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;
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 notdef
133                  printf("pixel %d = (%d,%d,%d) (%d refs)\n",
134 <                                h, r, g, b, p.e->n);
134 >                                h, r, g, b, clrtab[h].n);
135   #endif
136                  (*set_pixel)(h, r, g, b);
137          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines