]> hackdaworld.org Git - physik/nlsop.git/commitdiff
added 3dplot + linescan code
authorhackbard <hackbard>
Wed, 24 Nov 2004 18:12:45 +0000 (18:12 +0000)
committerhackbard <hackbard>
Wed, 24 Nov 2004 18:12:45 +0000 (18:12 +0000)
.cvsignore
3dplot.c [new file with mode: 0644]
linescan.c [new file with mode: 0644]
makefile

index b4cb7760654586e03fcaa491f18a2c5033556223..4da6a6a26c6f8bb7faf819e0bd3f7eb7e34c8710 100644 (file)
@@ -11,3 +11,5 @@ be2le
 dft
 *.bmp
 *.plot
+linescan
+3dplot
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;
+}
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;
+}
index 338db5d407cc0076170e067f94e362edb7f930b6..3f5b43de944e359ffb1b9ddaccaa3a6e1fee7222 100644 (file)
--- a/makefile
+++ b/makefile
@@ -10,7 +10,13 @@ OBJS = network.o event.o input.o display.o audio.o fourier.o bmp.o
 dft: links $(OBJS)
        $(CC) $(CFLAGS) -o $@ $(OBJS) dft.c $(LIBS)
 
-all: links dft
+linescan: links $(OBJS)
+       $(CC) $(CFLAGS) -o $@ $(OBJS) linescan.c $(LIBS)
+
+3dplot: links $(OBJS)
+       $(CC) $(CFLAGS) -o $@ $(OBJS) 3dplot.c $(LIBS)
+
+all: links dft linescan 3dplot
 
 clean:
        rm -f $(OBJS) ivac