added 3dplot + linescan code
[physik/nlsop.git] / 3dplot.c
diff --git a/3dplot.c b/3dplot.c
new file mode 100644 (file)
index 0000000..fbf1d2b
--- /dev/null
+++ b/3dplot.c
@@ -0,0 +1,47 @@
+/* 3dplot.c -- 3d plot bmp image */
+
+/*
+ * 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;
+  int help;
+  int val;
+
+  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);
+
+  for(x=0;x<bmp.info.width;x++) {
+    for(y=0;y<bmp.info.height;y++) {
+      help=y*bmp.info.width+x;
+      val=(bmp.map[help].r+bmp.map[help].g+bmp.map[help].b)/3;
+      if(val!=0)
+        printf("%f %f %d\n",1.0*(x-bmp.info.width/2)/(bmp.info.width*3),
+               1.0*(y-bmp.info.height/2)/(bmp.info.height*3),val);
+    }
+  }
+
+  bmp_shutdown(&bmp);
+
+  return 1;
+}