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

Contents of /eyes/find_grey_range.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations)
Sat Nov 12 21:31:09 2011 UTC (6 years, 11 months ago) by hib
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +45 -1 lines
File MIME type: text/plain
I think I got kristie working
1 #include <math.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include "holo_complex.h"
5
6
7 int main(int argc,char *argv[]) {
8 real greys[256];
9 real max;
10 real min;
11 int span;
12 int offset;
13 if (argc<3) {
14 fprintf(stderr,"usage: find_grey_range <mode> <files> >file.grey\n"
15 " where <mode> is all,real, or imaginary as pertaining to what we are averaging for\n"
16 " <files> is a list of floating point output files from build_double, usually with .fp extension\n");
17 exit(-1);
18 }
19 if (strcmp(argv[1],"all")==0) {
20 span=1;
21 offset=0;
22 }
23 else if (strcmp(argv[1],"real")==0) {
24 span=2;
25 offset=0;
26 }
27 else if (strcmp(argv[1],"imaginary")==0) {
28 span=2;
29 offset=1;
30 }
31 else if (strcmp(argv[1],"imaginary")==0) {
32 span=2;
33 offset=1;
34 }
35 else if (strcmp(argv[1],"estimate")==0) {
36 FILE *xf;
37 xf = fopen(argv[2],"r");
38 if (!xf) {
39 fprintf(stderr,"cant open file %s\n",argv[2]);
40 }
41 real tr = atof(argv[3]);
42 int bs=fread(greys,sizeof(real),256,xf);
43 int i;
44 double l=greys[0];
45 double h=greys[255];
46 if (l<0) l= -l;
47 if (l>h) h=l;
48 for (i=0;i<256;i++) {
49 greys[i] = greys[i] * tr/h;
50 }
51 for (i=0;i<256;i++) {
52 fprintf(stderr,"%d - %lf\n",i,greys[i]);
53 }
54 fwrite(greys,sizeof(real),256,stdout);
55 exit(0);
56
57 }
58 else if (strcmp(argv[1],"bound")==0) {
59 FILE *xf;
60 xf = fopen(argv[2],"r");
61 if (!xf) {
62 fprintf(stderr,"cant open file %s\n",argv[2]);
63 }
64 real tr = atof(argv[3]);
65 int bs=fread(greys,sizeof(real),256,xf);
66 int i;
67 greys[0]=-tr;
68 greys[255]=tr;
69 for (i=0;i<256;i++) {
70 fprintf(stderr,"%d - %lf\n",i,greys[i]);
71 }
72 fwrite(greys,sizeof(real),256,stdout);
73 exit(0);
74
75 }
76 else {
77 fprintf(stderr,"invaid mode, use real, imaginary, or all\n");
78 exit(-1);
79 }
80 find_min_max_from_files(argc-1,argv+1,offset,span,&min,&max);
81 fprintf(stderr,"min %lf max %lf\n",min,max);
82 compute_grey_from_files(argc-1,argv+1,greys,offset,span,0,256,min,max);
83
84 fwrite(greys,sizeof(real),256,stdout);
85 exit(0);
86
87 }

  ViewVC Help
Powered by ViewVC 1.1.5