From a4143fd2ebd9777182e2192309e3300773ae722f Mon Sep 17 00:00:00 2001 From: hackbard Date: Sun, 1 Aug 2004 18:34:58 +0000 Subject: [PATCH] added first attempts of fourier trafo code ... --- ft.c | 178 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ft.h | 22 ++++++++ 2 files changed, 200 insertions(+) create mode 100644 ft.c create mode 100644 ft.h diff --git a/ft.c b/ft.c new file mode 100644 index 0000000..0bef018 --- /dev/null +++ b/ft.c @@ -0,0 +1,178 @@ +/* ft.c - fourier transformation on nlsop save files */ + +/* + * author: frank.zirkelbach@physik.uni-augsburg.de + * + */ + +#include "ft.h" + +int usage(void) { + puts("usage:"); + puts("ft -i -o -itype -otype -d -g -debug "); + puts(""); + puts("i/o type may be bmp or nlsop"); + puts("dimensions: 2 or 3"); + puts("geometry in 2d: , eg: 64 32 0 80 (64x32 big area starting from (0|80)"); + puts("geometry in 3d: , eg: 64 64 32 0 0 80 (the same in 3 dimensions ^)"); + puts(""); + puts("you must set -dimensions before specifying -geometry"); + puts("default: dimension = 2 , resolution = whole image"); + return 1; +} + +int get_size_of_infile(int fd,int *res,unigned char set) { + + if(set&SET_IN_BMP) { + + unsigned char buf[BMP_HEADER_LEN]; + + puts("reading bmp header ..."); + read(fd,buf,BMP_HEADER_LEN); + res[0]=buf[18]|(buf[19]<<8); + res[1]=buf[22]|(buf[23]<<8); + + return ((int)buf[10]); + } + else { + + d3_lattice *d3l; + + puts("reading nlsop header ..."); + d3l=(d3_lattice *)malloc(sizeof(d3_lattice)); + read(fd,d3l,sizeof(d3_lattice)); + res[0]=d3l->max_x; + if(set&SET_3D) { + res[1]=d3l->max_y; + res[2]=d3l->max_z; + } else res[1]=d3l->max_z; + + return (sizeof(d3_lattice)+sizeof(info)); + } + +} + +int get_infile_data(int fd,int offset,int *RES,int *res,int *x,unsigned char *orig,unsigned char set) { + + int i,j,k,w_len; + unsigned char *buf; + + lseek(fd,offset,SEEK_SET); + + if(set&SET_IN_BMP) { + w_len=3*RES[1]; + w_len+=(4-w_len%4); + lseek(fd,x[1]*w_len,SEEK_CUR); + buf=(unsigned char)malloc(w_len); + for(j=0;j