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

Comparing ray/src/px/ciq.c (file contents):
Revision 1.3 by greg, Fri Apr 7 13:30:09 1989 UTC vs.
Revision 1.4 by ph, Fri Apr 7 16:36:12 1989 UTC

# Line 22 | Line 22 | int hist[len];         /* list of frequencies or pixelvalues
22   colormap color;         /* quantization colormap */
23   int n;                  /* number of colors in it */
24  
25 + #define ERRMAX 20       /* maximum allowed propagated error,
26 +                           if >=255 then no clamping */
27 +
28   /*----------------------------------------------------------------------*/
29  
30   ciq(dith,nw,synth,cm)
# Line 48 | Line 51 | colormap cm;           /* quantization colormap */
51      }
52      picwritecm(color);
53  
54 +    initializeclosest();
55      if (dith)
56          draw_dith(ocm);
57      else {
# Line 139 | Line 143 | colormap ocm;                  /* colormap for orig */
143          Q[0] = Q[1] = Q[2] = 0;
144          picreadline3(y,iline);
145          for (p=P, q=Q, x=0; x<xmax; x++, p+=3, q+=3) {
146 <            rr = ocm[0][iline[x].r]+p[0];
147 <            gg = ocm[1][iline[x].g]+p[1];       /* ideal */
148 <            bb = ocm[2][iline[x].b]+p[2];
146 >            rr = p[0];
147 >            if (rr<-ERRMAX) rr = -ERRMAX; else if (rr>ERRMAX) rr = ERRMAX;
148 >            gg = p[1];
149 >            if (gg<-ERRMAX) gg = -ERRMAX; else if (gg>ERRMAX) gg = ERRMAX;
150 >            bb = p[2];
151 >            if (bb<-ERRMAX) bb = -ERRMAX; else if (bb>ERRMAX) bb = ERRMAX;
152 >            /* now rr,gg,bb is propagated color */
153 >            rr += ocm[0][iline[x].r];
154 >            gg += ocm[1][iline[x].g];   /* ideal */
155 >            bb += ocm[2][iline[x].b];
156              if (rr<0) rr = 0; else if (rr>255) rr = 255;
157              if (gg<0) gg = 0; else if (gg>255) gg = 255;
158              if (bb<0) bb = 0; else if (bb>255) bb = 255;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines