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

Comparing ray/src/px/cut.c (file contents):
Revision 1.1 by greg, Thu Feb 2 10:49:12 1989 UTC vs.
Revision 2.4 by schorsch, Sun Mar 28 20:33:13 2004 UTC

# Line 1 | Line 1
1 /*
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
4 + /*
5   CUT - Median bisection (k-d tree) algorithm for color image quantization
6  
7   flaw: doesn't always create as many colors as requested
# Line 26 | Line 25 | struct plum {struct plum *next; int code;};
25   static short off[len];
26   /* color codes: offsets of colors in hist array */
27  
28 + static void splitbox(struct index *ii, struct index *io);
29  
30 < makecm(nw,na)                   /* subdivide colorspace to generate a colormap*/
31 < int nw,*na;                     /* number of colors wanted, actual */
30 >
31 > int
32 > makecm(                 /* subdivide colorspace to generate a colormap*/
33 >        int nw,
34 >        int *na                 /* number of colors wanted, actual */
35 > )
36   {
37      int i,m,n,freq,weight,sr,sg,sb;
38      short *o;
# Line 70 | Line 74 | int nw,*na;                    /* number of colors wanted, actual */
74      return n;
75   }
76  
77 < splitbox(ii,io)         /* split a box in two: half of the pixels from */
78 < struct index *ii,*io;   /* box ii will go into io, the other half into io+1 */
77 > static void
78 > splitbox(               /* split a box in two: half of the pixels from */
79 >        struct index *ii,       /* box ii will go into io, the other half into io+1 */
80 >        struct index *io
81 > )
82   {
83      register short *o,*o1,*o2;
84      register int shift,count,k,freq,r,g,b,r1,g1,b1,r2,g2,b2;
# Line 121 | Line 128 | struct index *ii,*io;  /* box ii will go into io, the o
128      }
129      io[0].o = o1;
130      io[0].freq = (freq>>1)-count;
131 <    io[1].freq = (freq+1>>1)+count;
131 >    io[1].freq = ((freq+1)>>1)+count;
132      /* printf(" at %3d %d=%d+%d\n",io[1].o-off,freq,io[0].freq,io[1].freq); */
133   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines