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

Contents of /eyes/xor.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Wed Jul 13 22:23:58 2016 UTC (21 months, 1 week ago) by hib
Branch: MAIN
CVS Tags: HEAD
File MIME type: text/plain
...
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <math.h>
4
5 #include "util.h"
6 /* usage xor two images xsize ysize f1 f2
7 xsize is doubled on the output
8 */
9 int main (int argc,char *argv[]) {
10 char *file1;
11 char *file2;
12 int xsize;
13 int ysize;
14 if (argc==5) {
15 xsize=atoi(argv[1]);
16 ysize=atoi(argv[2]);
17 file1=argv[3];
18 file2=argv[4];
19 }
20 else {
21 fprintf(stderr,"usage combine_two_images_interleaved xsize ysize f1 f2\n"
22 " xsize is doubled on the output\n"
23 "Where file has x|y|r|g|b text format\n");
24 exit(-1);
25 }
26 FILE *f1,*f2;
27 f1 = fopen(file1,"r");
28 f2 = fopen(file2,"r");
29 char f1buf[10001];
30 char f2buf[10001];
31 printf("# ImageMagick pixel enumeration: %d,%d,255,rgb\n",xsize,ysize);
32 while (fgets(f1buf,10000,f1)) {
33 char *q;
34 // fprintf(stderr,"b %s\n",basebuf);
35 q=fgets(f2buf,10000,f2);
36 int xb,yb,rb,gb,bb;
37 int xo,yo,ro,go,bo;
38 xb = fieldi(f1buf,0);
39 yb = fieldi(f1buf,1);
40 rb = fieldi(f1buf,2);
41 gb = fieldi(f1buf,3);
42 bb = fieldi(f1buf,4);
43 xo = fieldi(f2buf,0);
44 yo = fieldi(f2buf,1);
45 ro = fieldi(f2buf,2);
46 go = fieldi(f2buf,3);
47 bo = fieldi(f2buf,4);
48 if ((xb != xo)||(yb != yo)) {
49 fprintf(stderr,"error %d,%d %d,%d \n",
50 xb,yb,xo,yo);
51 continue;
52 }
53
54
55 if (rb >=128) {
56 if (ro>=128) {
57 rb=0;
58 }
59 else {
60 rb = 255;
61 }
62 }
63 else {
64 if (ro>=128) {
65 rb = 255;
66 }
67 else {
68 rb = 0;
69 }
70 }
71 gb = rb;
72 bb = rb;
73
74
75 int total;
76
77 total = rb*65536+gb*256+bb;
78 printf("%d,%d: (%d,%d,%d) #%06x rgb(%d,%d,%d)\n",
79 xb,yb,rb,gb,bb,total,rb,gb,bb);
80 }
81 }

  ViewVC Help
Powered by ViewVC 1.1.5