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

Contents of /eyes/hologram_over_picture.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations)
Sat Aug 17 21:34:31 2013 UTC (5 years, 1 month ago) by hib
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +20 -5 lines
File MIME type: text/plain
random doesnt work well. did other way
1 /* based on randomify - this reads the text for a base picture
2 and either will do a dark version of the pixel, or white
3 We might at some time make it porportional- but now is not that time */
4
5 #include <stdio.h>
6 #include <stdlib.h>
7
8 #include "util.h"
9
10
11
12 #ifdef BEN
13
14 int main () {
15 FILE *base,*other,*alpha,*hologram;
16 base = fopen("base.txt","r");
17 hologram = fopen("l.txt","r"); /* optional */
18 if (hologram) {
19 fprintf(stderr,"hologram found and being used as a base\n");
20 }
21 char basebuf[10001];
22 char otherbuf[10001];
23 char alphabuf[10001];
24 char hologrambuf[10001];
25 srand(4);
26 /*printf("# ImageMagick pixel enumeration: 18000,18000,255,rgb\n");*/
27 /*printf("# ImageMagick pixel enumeration: 9450,12600,255,rgb\n");*/
28 //printf("# ImageMagick pixel enumeration: 4725,6300,255,rgb\n");
29 printf("# ImageMagick pixel enumeration: 7200,900,255,rgb\n");
30 while (fgets(basebuf,10000,base)) {
31 char *q;
32 if (hologram) q=fgets(hologrambuf,10000,hologram);
33 int xb,yb,rb,gb,bb;
34 int xo,yo,ro,go,bo;
35 int xa,ya,ra,ga,ba;
36 int hb;
37 xb = fieldi(basebuf,0);
38 yb = fieldi(basebuf,1);
39 rb = fieldi(basebuf,2);
40 gb = fieldi(basebuf,3);
41 bb = fieldi(basebuf,4);
42 hb = fieldi(hologrambuf,2);
43
44 /* This section is for full color pixel transfer */
45 int rf,gf,bf;
46 int r;
47 r=hb;
48 #ifdef four_three
49 if (r<128) {
50 rf = rb * 4 / 3;
51 if (rf > 255) rf=255;
52 gf = gb * 4 / 3;
53 if (gf > 255) gf=255;
54 bf = bb * 4 / 3;
55 if (bf > 255) bf=255;
56 /*
57 rf = 255;
58 gf = 255;
59 bf = 255;
60 */
61 }
62 else {
63 rf = rb / 2;
64 gf = gb / 2;
65 bf = bb / 2;
66 }
67 #endif
68 rf = (rb * r * 2) / 255;
69 gf = (gb *r * 2) / 255;
70 bf = (bb * r * 2) / 255;
71 rf = (rf + rb) / 2;
72 gf = (gf + gb) / 2;
73 bf = (bf + bb) / 2;
74
75 if (rf > 255) rf=255;
76 if (gf > 255) gf=255;
77 if (bf > 255) bf=255;
78
79
80 int total;
81 total = rf*65536+gf*256+bf;
82 printf("%d,%d: (%d,%d,%d) #%06x rgb(%d,%d,%d)\n",
83 xb,yb,rf,gf,bf,total,rf,gf,bf);
84 }
85 }
86 #endif
87
88
89 /* # define FADE_FOR_FABRIC was to fase it for thge fabrick output of tests */
90
91
92
93 int main (int argc, char *argv[]) {
94 FILE *base,*hologram;
95 int xsize,ysize;
96 if (argc != 5) {
97 fprintf(stderr,"Usage: %s <xsize> <ysize> <base_filename> <hologram_filename>\n",argv[0]);
98 exit(-1);
99 }
100 xsize = atoi(argv[1]);
101 ysize = atoi(argv[2]);
102 char *image_filename = argv[3];
103 char *hologram_filename = argv[4];
104 base = fopen(image_filename,"r");
105 hologram = fopen(hologram_filename,"r");
106
107 /*
108 base = fopen("tilified_awaiting_hologram2.txt","r");
109 hologram = fopen("hologram.txt","r"); // optional
110 */
111 if (hologram) {
112 fprintf(stderr,"hologram found and being used as a base\n");
113 }
114 char basebuf[10001];
115 char hologrambuf[10001];
116 srand(4);
117 /*printf("# ImageMagick pixel enumeration: 18000,18000,255,rgb\n");*/
118 /*printf("# ImageMagick pixel enumeration: 9450,12600,255,rgb\n");*/
119 //printf("# ImageMagick pixel enumeration: 7200,900,255,rgb\n");
120 //printf("# ImageMagick pixel enumeration: 60480,7560,255,rgb\n");
121 printf("# ImageMagick pixel enumeration: %d,%d,255,rgb\n",xsize,ysize);
122 while (fgets(basebuf,10000,base)) {
123 char *q;
124 if (hologram) q=fgets(hologrambuf,10000,hologram);
125 int xb,yb,rb,gb,bb;
126 int xo,yo,ro,go,bo;
127 int xa,ya,ra,ga,ba;
128 int hb;
129 xb = fieldi(basebuf,0);
130 yb = fieldi(basebuf,1);
131 rb = fieldi(basebuf,2);
132 gb = fieldi(basebuf,3);
133 bb = fieldi(basebuf,4);
134 hb = fieldi(hologrambuf,2);
135
136 #ifdef FADE_FOR_FABRIC
137 rb = (rb*199)/256+23;
138 gb = (gb*199)/256+23;
139 bb = (bb*199)/256+23;
140 #endif
141
142 /* This section is for full color pixel transfer */
143 int rf,gf,bf;
144 int r;
145 r=hb;
146 if (r ==127) {
147 rf=rb;gf=gb;bf=bb;
148 }
149 else {
150 find_the_two_colors(rb,gb,bb,50,&ro,&ra,&go,&ga,&bo,&ba);
151 if (r>127) {
152 rf=ra;
153 gf=ga;
154 bf=ba;
155 }
156 else {
157 rf=ro;
158 gf=go;
159 bf=bo;
160 }
161 }
162
163
164 int total;
165 total = rf*65536+gf*256+bf;
166 printf("%d,%d: (%d,%d,%d) #%06x rgb(%d,%d,%d)\n",
167 xb,yb,rf,gf,bf,total,rf,gf,bf);
168 }
169 }

  ViewVC Help
Powered by ViewVC 1.1.5