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

Contents of /eyes/encirculate.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations)
Tue Jul 24 10:18:46 2012 UTC (6 years, 3 months ago) by hib
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +24 -11 lines
File MIME type: text/plain
cleanup
1 /*38272*/
2 #define BLACKANDWHITE
3 /*define INBW 1*/
4 /*define INN 1*/
5
6 #include <stdio.h>
7 #include <stdlib.h>
8
9 #include "util.h"
10
11 int main (int argc,char *argv[]) {
12
13 int diameter = atoi(argv[1]);
14 double ddiameter = diameter;
15
16 double cx = atof(argv[2]);
17 double cy = atof(argv[3]);
18
19 double radius=ddiameter*0.5;
20 double radius_squared = radius*radius;
21 char basebuf[10001];
22 int fromx,tox,fromy,toy;
23 fromx = (int)cx - (diameter+1)/2;
24 fromy = (int)cy - (diameter+1)/2;
25 tox = (int)cx + (diameter+1)/2;
26 toy = (int)cy + (diameter+1)/2;
27 fprintf(stderr,"from %d,%d to %d,%d\n",fromx,fromy,tox,toy);
28
29 printf("# ImageMagick pixel enumeration: %d,%d,255,rgb\n",diameter,diameter);
30 while (fgets(basebuf,10000,stdin)) {
31 int xb,yb,rb,gb,bb;
32 int rf,gf,bf;
33 xb = fieldi(basebuf,0);
34 yb = fieldi(basebuf,1);
35 rb = fieldi(basebuf,2);
36 gb = fieldi(basebuf,3);
37 bb = fieldi(basebuf,4);
38 if (xb < fromx) continue;
39 if (xb -fromx >=diameter) continue;
40 if (yb < fromy) continue;
41 if (yb -fromy >=diameter) break;
42 if ((xb ==fromx)&&(yb % 100 == 0)) {
43 fprintf(stderr,"yb %d\r",yb);
44 }
45 double dx = ((double)(xb)) - cx;
46 double dy = ((double)(yb)) - cy;
47 double d=dx*dx + dy*dy;
48 if (d>radius_squared) {
49 rf = 255;
50 gf = 255;
51 bf=255;
52 }
53 else {
54 #ifdef BLACKANDWHITE
55 if (rb >= 128) {
56 rf = 255;
57 gf = 0;
58 bf = 61;
59 }
60 else {
61 rf = 121;
62 gf = 0;
63 bf = 29;
64 }
65 #else
66 #ifdef INBW
67 if (rb >= 128) {
68 rf = 255;
69 gf = 255;
70 bf = 00; /* yellow */
71 }
72 else {
73 rf = 128; /* deep purple */
74 gf = 0;
75 bf = 128;
76 }
77 #else
78 #ifdef INN
79 rf = rb;
80 gf = gb;
81 bf = bb;
82 #else
83 /* 188 0 45 is the perfect red */
84 /* We will shift.
85 255 - 188 is 67
86 188 - 67 is 121
87 so for red we go from 121 to 255 which averages to 188
88 green is 0 - is always 0
89 Blue - 45
90 255 - 45 = 210
91 0 - 90 would average 45
92 This would probably be the best colorwise - but the best effect wise would be from
93
94 But the true bleue ration is 29 - 61 so that is what we will use for blue
95
96
97 94 0 23 to 255 255 255
98 byt that averages out to
99 178 128 100
100 Not the right color.
101 */
102 rf = (rb * (255-121))/255 + 121; /* 255 becomes 188 */
103 gf = 0;
104 bf = (bb * (61-29))/255 + 29; /* Cool */
105 #endif
106 #endif
107 #endif
108 }
109 int total;
110 total = rf*65536+gf*256+bf;
111 printf("%d,%d: (%d,%d,%d) #%06x rgb(%d,%d,%d)\n",
112 xb-fromx,yb-fromy,rf,gf,bf,total,rf,gf,bf);
113
114 }
115 exit(0);
116 }

  ViewVC Help
Powered by ViewVC 1.1.5