/[opencvs]/eyes/rgbify.c
ViewVC logotype

Contents of /eyes/rgbify.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Sat Jul 23 02:18:56 2011 UTC (7 years, 3 months ago) by hib
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +2 -1 lines
File MIME type: text/plain
japan was made but not printed
Also Larissa was made and not printed.
We also cleaned up Enlightenmnet instructions better and set up base "sets" at various resolutions.
1 #include <stdio.h>
2 #include <stdlib.h>
3
4 /* This roughly converts a bw signal to a color
5 having blue go to purple to white.
6 The idea is to amke one that does this in the cmyk colorspace so that
7 we can add some color spark to the hologram
8
9
10 instead of percentages, we will do in range of 256.
11 30 59 and 11 convert to
12 76 152 and 28
13 inverse is
14 179 103 and 227
15 */
16
17 #include "util.h"
18
19 int main () {
20 FILE *base;
21 base=stdin;
22 char basebuf[10001];
23 srand(42);
24 /*printf("# ImageMagick pixel enumeration: 17900,17900,255,rgb\n");*/
25 /*printf("# ImageMagick pixel enumeration: 1440,1440,255,rgb\n");*/
26 printf("# ImageMagick pixel enumeration: 38880,38880,255,rgb\n");
27 int qq=0;
28 while (fgets(basebuf,10000,base)) {
29 char *q;
30 int xb,yb,rb,gb,bb;
31 xb = fieldi(basebuf,0);
32 yb = fieldi(basebuf,1);
33 rb = fieldi(basebuf,2);
34 gb = fieldi(basebuf,3);
35 bb = fieldi(basebuf,4);
36 int r;
37 r = (random()>>2) % 3;
38 r= qq/2;
39 int max,min;
40 r=0; /* pheonix */
41 if (r==0) { /* red first */
42 max = rb * 256 / 76; /* largest r value */
43 if (max > 255) max=255;
44 min = (rb - 179) * 256 / 76;
45 if (min<0) min=0;
46 /* so the lowest we can go is min, and the highest is max */
47 if (min>=max) rb=max;
48 else rb = min + (random()>>2) % (max-min);
49 rb=max; /* pheonix */
50
51 bb = gb = gb - (rb * 76 / 256);
52
53 r = (random()>>2) % 2;
54 r = qq % 2;
55 if (r==0) { /* green second */
56 max = gb * 256 / 152;
57 if (max > 255) max=255;
58 min = (gb - 28 ) * 256 / 152;
59 if (min<0) min=0;
60 /* so the lowest we can go is min, and the highest is max */
61
62 if (min>=max) gb=max;
63 else gb = min + (random()>>2) % (max-min);
64
65 bb = bb - (gb * 152 / 256);
66 bb = bb * 256 / 28;
67 if (bb<0) bb=0;
68 if (bb>255) bb=255;
69 }
70 else { /* blue second */
71 max = bb * 256 / 28;
72 if (max > 255) max=255;
73 min = (bb - 152 ) * 256 / 28;
74 if (min<0) min=0;
75 /* so the lowest we can go is min, and the highest is max */
76 if (min>=max) bb=max;
77 else bb = min + (random()>>2) % (max-min);
78
79 gb = gb - (bb * 28 / 256);
80 gb = gb * 256 / 152;
81 if (gb<0) gb=0;
82 if (gb>255) gb=255;
83 }
84 }
85 else if (r==1) { /* green first */
86 max = gb * 256 / 152; /* largest r value */
87 if (max > 255) max=255;
88 min = (gb - 103) * 256 / 152;
89 if (min<0) min=0;
90 /* so the lowest we can go is min, and the highest is max */
91
92 if (min>=max) gb=max;
93 else gb = min + (random()>>2) % (max-min);
94
95 rb = bb = bb - (gb * 152 / 256);
96
97
98 r = (random()>>2) % 2;
99 r = qq % 2;
100 if (r==0) { /* red second */
101 max = rb * 256 / 78;
102 if (max > 255) max=255;
103 min = (rb - 28 ) * 256 / 78;
104 if (min<0) min=0;
105 /* so the lowest we can go is min, and the highest is max */
106
107 if (min>=max) rb=max;
108 else rb = min + (random()>>2) % (max-min);
109
110 bb = bb - (rb * 78 / 256);
111 bb = bb * 256 / 28;
112 if (bb<0) bb=0;
113 if (bb>255) bb=255;
114 }
115 else { /* blue second */
116 max = bb * 256 / 28;
117 if (max > 255) max=255;
118 min = (bb - 78 ) * 256 / 28;
119 if (min<0) min=0;
120 /* so the lowest we can go is min, and the highest is max */
121 if (min>=max) bb=max;
122 else bb = min + (random()>>2) % (max-min);
123
124 rb = rb - (bb * 28 / 256);
125 rb = rb * 256 / 76;
126 if (rb<0) rb=0;
127 if (rb>255) rb=255;
128 }
129 }
130 else { /* blue first */
131 max = bb * 256 / 28;
132 if (max > 255) max=255;
133 min = (bb - 227 ) * 256 / 28;
134 if (min<0) min=0;
135 /* so the lowest we can go is min, and the highest is max */
136 if (min>=max) bb=max;
137 else bb = min + (random()>>2) % (max-min);
138
139 rb = gb = rb - (bb * 28 / 256);
140
141
142 r = (random()>>2) % 2;
143 r = qq % 2;
144 if (r==0) { /* red second */
145 max = rb * 256 / 78;
146 if (max > 255) max=255;
147 min = (rb - 152 ) * 256 / 78;
148 if (min<0) min=0;
149 /* so the lowest we can go is min, and the highest is max */
150
151 if (min>=max) rb=max;
152 else rb = min + (random()>>2) % (max-min);
153
154 gb = gb - (rb * 78 / 256);
155 gb = gb * 256 / 152;
156 if (gb<0) gb=0;
157 if (gb>255) gb=255;
158 }
159 else { /* green second */
160 max = gb * 256 / 152;
161 if (max > 255) max=255;
162 min = (gb - 76 ) * 256 / 152;
163 if (min<0) min=0;
164 /* so the lowest we can go is min, and the highest is max */
165
166 if (min>=max) gb=max;
167 else gb = min + (random()>>2) % (max-min);
168
169 rb = rb - (gb * 152 / 256);
170 rb = rb * 256 / 76;
171 if (rb<0) rb=0;
172 if (rb>255) rb=255;
173 }
174 }
175
176 int total;
177 total = rb*65536+gb*256+bb;
178 printf("%d,%d: (%d,%d,%d) #%06x rgb(%d,%d,%d)\n",
179 xb,yb,rb,gb,bb,total,rb,gb,bb);
180 qq = (qq+1)%6;
181 }
182 }

  ViewVC Help
Powered by ViewVC 1.1.5