X-Git-Url: https://hackdaworld.org/gitweb/?p=physik%2Fnlsop.git;a=blobdiff_plain;f=dft.c;h=1d26cee7a2a1e6ab25c5cb003fed73d9c189861c;hp=3ce41a40f88c278684353d0797e2f04790cd46a9;hb=0dcd23ead2402b25e59a63668c16d375f031177d;hpb=dc8e4ecbb7c31b702518a819190facd40f346247 diff --git a/dft.c b/dft.c index 3ce41a4..1d26cee 100644 --- a/dft.c +++ b/dft.c @@ -12,6 +12,7 @@ int main(int argc,char **argv) { t_fourier fourier; t_bmp src; t_bmp dst; + t_bmp cut; int x,y; int offy,offt; int scale; @@ -20,6 +21,7 @@ int main(int argc,char **argv) { bmp_init(&src,1); bmp_init(&dst,1); + bmp_init(&cut,1); src.mode=READ; dst.mode=WRITE; strcpy(src.file,argv[1]); @@ -31,12 +33,14 @@ int main(int argc,char **argv) { bmp_read_file(&src); - dst.width=src.info.width; - dst.height=src.info.height; + bmp_cut_grab_bottom(&cut,&src,src.info.width,GRAB); + + dst.width=cut.width; + dst.height=cut.height; bmp_alloc_map(&dst); - fourier.data_len[0]=src.info.width; - fourier.data_len[1]=src.info.height; + fourier.data_len[0]=cut.width; + fourier.data_len[1]=cut.height; fourier_alloc_data(&fourier); mag=(double *)malloc(fourier.data_len[0]*fourier.data_len[1]*sizeof(double)); @@ -62,14 +66,13 @@ int main(int argc,char **argv) { // copy back the data, intensity = sqrt(r^2+i^2) max=0; - offy=0; + offt=0; for(y=0;ymax) max=mag[offt]; + offt+=1; } - offy+=fourier.data_len[0]; } printf("found max: %f\n",max); @@ -79,10 +82,19 @@ int main(int argc,char **argv) { if(scale!=0) { printf("scaling image intensity: %d\n",scale); - for(x=0;x