added 3dplot + linescan code
[physik/nlsop.git] / linescan.c
diff --git a/linescan.c b/linescan.c
new file mode 100644 (file)
index 0000000..11a2b5f
--- /dev/null
@@ -0,0 +1,42 @@
+/* linescan.c -- linescan @ width/2 */
+
+/*
+ * author: frank.zirkelbach@physik.uni-augsburg.de
+ *
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+
+#include <stdio.h>
+#include "bmp.h"
+
+int main(int argc,char **argv) {
+
+  t_bmp bmp;
+  int x,y;
+
+  if(argc!=2) {
+    printf("usage: %s <filename>\n",argv[0]);
+    return -1;
+  }
+
+  bmp_init(&bmp,2);
+  bmp.mode=READ;
+  strcpy(bmp.file,argv[1]);
+
+  bmp_read_file(&bmp);
+
+  dprintf(2,"width = %d\n",bmp.info.width);
+
+  x=bmp.info.width/2;
+  for(y=0;y<bmp.info.height;y++) {
+    printf("%f %d\n",1.0*(bmp.info.height/2-y)/(bmp.info.width*3),
+                     (bmp.map[x].r+bmp.map[x].g+bmp.map[x].b)/3);
+    x+=bmp.info.width;
+  }
+
+  bmp_shutdown(&bmp);
+
+  return 1;
+}