fixed nlsop for packaging ..
[physik/nlsop.git] / linescan.c
1 /* linescan.c -- linescan @ width/2 */
2
3 /*
4  * author: frank.zirkelbach@physik.uni-augsburg.de
5  *
6  */
7
8 #define _GNU_SOURCE
9 #include <stdio.h>
10
11 #include <stdio.h>
12 #include "bmp.h"
13
14 #define DX (3)
15
16 int main(int argc,char **argv) {
17
18   t_bmp bmp;
19   int i,x,y,d;
20   double *val=NULL;
21   char set=1;
22
23   for(i=1;i<argc;i++) {
24
25     bmp_init(&bmp,2);
26     bmp.mode=READ;
27     strcpy(bmp.file,argv[i]);
28     bmp_read_file(&bmp);
29
30     if(set) {
31       val=(double *)malloc(bmp.info.height*sizeof(double));
32       if(val==NULL) {
33         printf("malloc failed!\n");
34         return -23;
35       }
36       memset(val,0,bmp.info.height*sizeof(double));
37       set=0;
38     }
39
40     x=bmp.info.width/2;
41     for(y=0;y<bmp.info.height;y++) {
42       for(d=-DX;d<=DX;d++)
43         val[y]+=(1.0*(bmp.map[x+d].r+bmp.map[x+d].g+bmp.map[x+d].b)/3);
44       x+=bmp.info.width; // jump to [x/2][y+1]
45     }
46
47     bmp_shutdown(&bmp);
48
49   }
50
51   for(y=0;y<bmp.info.height;y++) {
52     val[y]/=(argc-1);
53     printf("%f %f\n",1.0*(bmp.info.height/2-y)/(bmp.info.width*3),val[y]);
54     //printf("%f %f\n",1.0*(bmp.info.height/2-y)/(bmp.info.width),val[y]);
55   }
56
57   free(val);
58
59   return 1;
60 }