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

Comparing ray/src/px/neuclrtab.c (file contents):
Revision 2.12 by greg, Mon Sep 19 02:23:58 2005 UTC vs.
Revision 2.14 by greg, Fri May 20 02:06:39 2011 UTC

# Line 24 | Line 24 | static const char      RCSid[] = "$Id$";
24   #define neu_dith_colrs  dith_colrs
25   #endif
26                                  /* our color table (global) */
27 < extern BYTE     clrtab[256][3];
27 > extern uby8     clrtab[256][3];
28   static int      clrtabsiz;
29  
30   #ifndef DEFSMPFAC
# Line 36 | Line 36 | int    samplefac = DEFSMPFAC;  /* sampling factor */
36                  /* Samples array starts off holding spacing between adjacent
37                   * samples, and ends up holding actual BGR sample values.
38                   */
39 < static BYTE     *thesamples;
39 > static uby8     *thesamples;
40   static int      nsamples;
41 < static BYTE     *cursamp;
41 > static uby8     *cursamp;
42   static long     skipcount;
43  
44   #define MAXSKIP         (1<<24-1)
# Line 71 | Line 71 | neu_init(              /* initialize our sample array */
71          nsamples = npixels/samplefac;
72          if (nsamples < 600)
73                  return(-1);
74 <        thesamples = (BYTE *)malloc(nsamples*3);
74 >        thesamples = (uby8 *)malloc(nsamples*3);
75          if (thesamples == NULL)
76                  return(-1);
77          cursamp = thesamples;
# Line 100 | Line 100 | neu_init(              /* initialize our sample array */
100  
101   extern void
102   neu_pixel(                      /* add pixel to our samples */
103 <        register BYTE   col[]
103 >        register uby8   col[]
104   )
105   {
106          if (!skipcount--) {
# Line 148 | Line 148 | neu_clrtab(            /* make new color table using ncolors */
148                                  /* we're done with our samples */
149          free((void *)thesamples);
150                                  /* reset dithering function */
151 <        neu_dith_colrs((BYTE *)NULL, (COLR *)NULL, 0);
151 >        neu_dith_colrs((uby8 *)NULL, (COLR *)NULL, 0);
152                                  /* return new color table size */
153          return(clrtabsiz);
154   }
# Line 156 | Line 156 | neu_clrtab(            /* make new color table using ncolors */
156  
157   extern int
158   neu_map_pixel(          /* get pixel for color */
159 <        register BYTE   col[]
159 >        register uby8   col[]
160   )
161   {
162          return(inxsearch(col[BLU],col[GRN],col[RED]));
# Line 165 | Line 165 | neu_map_pixel(         /* get pixel for color */
165  
166   extern void
167   neu_map_colrs(  /* convert a scanline to color index values */
168 <        register BYTE   *bs,
168 >        register uby8   *bs,
169          register COLR   *cs,
170          register int    n
171   )
# Line 179 | Line 179 | neu_map_colrs( /* convert a scanline to color index va
179  
180   extern void
181   neu_dith_colrs( /* convert scanline to dithered index values */
182 <        register BYTE   *bs,
182 >        register uby8   *bs,
183          register COLR   *cs,
184          int     n
185   )
# Line 233 | Line 233 | neu_dith_colrs(        /* convert scanline to dithered index
233   #define lengthcount     (nsamples*3)
234   #define samplefac       1
235  
236 < /*----------------------------------------------------------------------*/
237 < /*                                                                      */
238 < /*                              NeuQuant                                */
239 < /*                              --------                                */
240 < /*                                                                      */
241 < /*              Copyright: Anthony Dekker, November 1994                */
242 < /*                                                                      */
243 < /* This program performs colour quantization of graphics images (SUN    */
244 < /* raster files).  It uses a Kohonen Neural Network.  It produces       */
245 < /* better results than existing methods and runs faster, using minimal  */
246 < /* space (8kB plus the image itself).  The algorithm is described in    */
247 < /* the paper "Kohonen Neural Networks for Optimal Colour Quantization"  */
248 < /* to appear in the journal "Network: Computation in Neural Systems".   */
249 < /* It is a significant improvement of an earlier algorithm.             */
250 < /*                                                                      */
251 < /* This program is distributed free for academic use or for evaluation  */
252 < /* by commercial organizations.                                         */
253 < /*                                                                      */
254 < /*      Usage:  NeuQuant -n inputfile > outputfile                      */
255 < /*                                                                      */
256 < /* where n is a sampling factor for neural learning.                    */
257 < /*                                                                      */
258 < /* Program performance compared with other methods is as follows:       */
259 < /*                                                                      */
260 < /*      Algorithm               |  Av. CPU Time |  Quantization Error   */
261 < /*      -------------------------------------------------------------   */
262 < /*      NeuQuant -3             |  314          |  5.55                 */
263 < /*      NeuQuant -10            |  119          |  5.97                 */
264 < /*      NeuQuant -30            |  65           |  6.53                 */
265 < /*      Oct-Trees               |  141          |  8.96                 */
266 < /*      Median Cut (XV -best)   |  420          |  9.28                 */
267 < /*      Median Cut (XV -slow)   |  72           |  12.15                */
268 < /*                                                                      */
269 < /* Author's address:    Dept of ISCS, National University of Singapore  */
270 < /*                      Kent Ridge, Singapore 0511                      */
271 < /* Email:       [email protected]                                     */
272 < /*----------------------------------------------------------------------*/
236 > /* NeuQuant Neural-Net Quantization Algorithm Interface
237 > * ----------------------------------------------------
238 > *
239 > * Copyright (c) 1994 Anthony Dekker
240 > *
241 > * NEUQUANT Neural-Net quantization algorithm by Anthony Dekker, 1994.
242 > * See "Kohonen neural networks for optimal colour quantization"
243 > * in "Network: Computation in Neural Systems" Vol. 5 (1994) pp 351-367.
244 > * for a discussion of the algorithm.
245 > * See also  http://members.ozemail.com.au/~dekker/NEUQUANT.HTML
246 > *
247 > * Any party obtaining a copy of these files from the author, directly or
248 > * indirectly, is granted, free of charge, a full and unrestricted irrevocable,
249 > * world-wide, paid up, royalty-free, nonexclusive right and license to deal
250 > * in this software and documentation files (the "Software"), including without
251 > * limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
252 > * and/or sell copies of the Software, and to permit persons who receive
253 > * copies from any such party to do so, with the only requirement being
254 > * that this copyright notice remain intact.
255 > */
256  
257   #define bool            int
258   #define false           0

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines