1 |
– |
/* Copyright 1988 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
CUT - Median bisection (k-d tree) algorithm for color image quantization |
6 |
|
|
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; |
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; |
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 |
|
} |