--- ray/src/px/cut.c 1989/02/02 10:49:12 1.1 +++ ray/src/px/cut.c 2004/03/28 20:33:13 2.4 @@ -1,8 +1,7 @@ -/* - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: cut.c,v 2.4 2004/03/28 20:33:13 schorsch Exp $"; #endif +/* CUT - Median bisection (k-d tree) algorithm for color image quantization flaw: doesn't always create as many colors as requested @@ -26,9 +25,14 @@ struct plum {struct plum *next; int code;}; static short off[len]; /* color codes: offsets of colors in hist array */ +static void splitbox(struct index *ii, struct index *io); -makecm(nw,na) /* subdivide colorspace to generate a colormap*/ -int nw,*na; /* number of colors wanted, actual */ + +int +makecm( /* subdivide colorspace to generate a colormap*/ + int nw, + int *na /* number of colors wanted, actual */ +) { int i,m,n,freq,weight,sr,sg,sb; short *o; @@ -70,8 +74,11 @@ int nw,*na; /* number of colors wanted, actual */ return n; } -splitbox(ii,io) /* split a box in two: half of the pixels from */ -struct index *ii,*io; /* box ii will go into io, the other half into io+1 */ +static void +splitbox( /* split a box in two: half of the pixels from */ + struct index *ii, /* box ii will go into io, the other half into io+1 */ + struct index *io +) { register short *o,*o1,*o2; register int shift,count,k,freq,r,g,b,r1,g1,b1,r2,g2,b2; @@ -121,6 +128,6 @@ struct index *ii,*io; /* box ii will go into io, the o } io[0].o = o1; io[0].freq = (freq>>1)-count; - io[1].freq = (freq+1>>1)+count; + io[1].freq = ((freq+1)>>1)+count; /* printf(" at %3d %d=%d+%d\n",io[1].o-off,freq,io[0].freq,io[1].freq); */ }