ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/biq.c
Revision: 2.1
Committed: Tue Nov 12 16:04:14 1991 UTC (32 years, 5 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 1.5: +0 -0 lines
Log Message:
updated revision number for release 2.0

File Contents

# Content
1 /* Copyright 1988 Regents of the University of California */
2
3 #ifndef lint
4 static char SCCSid[] = "$SunId$ LBL";
5 #endif
6
7 /*
8 * biq.c - simple greyscale quantization.
9 *
10 * 9/19/88
11 */
12
13 #include "standard.h"
14 #include "ciq.h"
15
16
17 biq(dith,nw,synth,cm)
18 int dith; /* is dithering desired? 0=no, 1=yes */
19 int nw; /* number of colors wanted in output image */
20 int synth; /* synthesize colormap? 0=no, 1=yes */
21 colormap cm; /* quantization colormap */
22 /* read if synth=0; always written */
23 {
24 colormap ocm;
25
26 picreadcm(ocm); /* read original picture's colormap (usually identity)*/
27
28 for (n = 0; n < nw; n++) /* also sets n to nw */
29 color[0][n] = color[1][n] = color[2][n] = (n*256L+128)/nw;
30
31 picwritecm(color);
32
33 draw_grey(ocm);
34
35 bcopy((char *)color,(char *)cm,sizeof color);
36 }
37
38 /*----------------------------------------------------------------------*/
39
40 draw_grey(ocm)
41 colormap ocm;
42 {
43 register rgbpixel *linin;
44 register pixel *linout;
45 rgbpixel intmp;
46 int outtmp;
47 int y;
48 register int x;
49
50 linin = line3alloc(xmax);
51 linout = linealloc(xmax);
52
53 for (y = 0; y < ymax; y++) {
54 picreadline3(y, linin);
55 for (x = 0; x < xmax; x++) {
56 intmp.r = ocm[0][linin[x].r];
57 intmp.g = ocm[1][linin[x].g];
58 intmp.b = ocm[2][linin[x].b];
59 outtmp = rgb_bright(&intmp);
60 linout[x] = (outtmp*n+n/2)/256;
61 }
62 picwriteline(y, linout);
63 }
64 free((char *)linin);
65 free((char *)linout);
66 }