--- ray/src/px/neuclrtab.c 1994/11/21 15:56:20 2.6 +++ ray/src/px/neuclrtab.c 2003/02/22 02:07:27 2.9 @@ -1,9 +1,6 @@ -/* Copyright (c) 1994 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: neuclrtab.c,v 2.9 2003/02/22 02:07:27 greg Exp $"; #endif - /* * Neural-Net quantization algorithm based on work of Anthony Dekker */ @@ -51,7 +48,9 @@ static long skipcount; #define setskip(sp,n) ((sp)[0]=(n)>>16,(sp)[1]=((n)>>8)&255,(sp)[2]=(n)&255) +static cpyclrtab(); + neu_init(npixels) /* initialize our sample array */ long npixels; { @@ -132,7 +131,7 @@ int ncolors; cpyclrtab(); inxbuild(); /* we're done with our samples */ - free((char *)thesamples); + free((void *)thesamples); /* reset dithering function */ neu_dith_colrs((BYTE *)NULL, (COLR *)NULL, 0); /* return new color table size */ @@ -172,7 +171,7 @@ int n; if (n != N) { /* get error propogation array */ if (N) { - free((char *)cerr); + free((void *)cerr); cerr = NULL; } if (n) @@ -257,7 +256,7 @@ int n; #define true 1 /* network defs */ -#define netsize 256 /* number of colours - can change this */ +#define netsize clrtabsiz /* number of colours - can change this */ #define maxnetpos (netsize-1) #define netbiasshift 4 /* bias for colour values */ #define ncycles 100 /* no. of learning cycles */ @@ -272,7 +271,7 @@ int n; #define betagamma (intbias<<(gammashift-betashift)) /* defs for decreasing radius factor */ -#define initrad (netsize>>3) /* for 256 cols, radius starts */ +#define initrad (256>>3) /* for 256 cols, radius starts */ #define radiusbiasshift 6 /* at 32.0 biased by 6 bits */ #define radiusbias (((int) 1)<=0)) { - if (i=0)) { + if (i= bestd) i = clrtabsiz; /* stop iter */ + if (dist >= bestd) i = netsize; /* stop iter */ else { i++; if (dist<0) dist = -dist; @@ -418,7 +417,7 @@ register int b,g,r; /* finds closest neuron (min dist) and updates freq */ /* finds best neuron (min dist-bias) and returns position */ /* for frequently chosen neurons, freq[i] is high and bias[i] is negative */ -/* bias[i] = gamma*((1/clrtabsiz)-freq[i]) */ +/* bias[i] = gamma*((1/netsize)-freq[i]) */ int contest(b,g,r) /* accepts biased BGR values */ register int b,g,r; @@ -434,7 +433,7 @@ register int b,g,r; p = bias; f = freq; - for (i=0; iclrtabsiz) hi=clrtabsiz; + hi = i+rad; if (hi>netsize) hi=netsize; j = i+1; k = i-1; @@ -572,7 +571,7 @@ unbiasnet() { int i,j; - for (i=0; i>= netbiasshift; network[i][3] = i; /* record colour no */ @@ -587,7 +586,7 @@ cpyclrtab() { register int i,j,k; - for (j=0; j