X-Git-Url: https://hackdaworld.org/gitweb/?p=physik%2Fnlsop.git;a=blobdiff_plain;f=dft.c;h=1d26cee7a2a1e6ab25c5cb003fed73d9c189861c;hp=385c22d01b6e3261a5507e894825801e1db285ff;hb=e7f9c4ef1dd8eb2a19fe98091db7d06834643ea9;hpb=ba07742cd1c1cf50e5467462311425cfdf245402 diff --git a/dft.c b/dft.c index 385c22d..1d26cee 100644 --- a/dft.c +++ b/dft.c @@ -12,30 +12,102 @@ 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; + double max; + double *mag; bmp_init(&src,1); bmp_init(&dst,1); + bmp_init(&cut,1); src.mode=READ; dst.mode=WRITE; strcpy(src.file,argv[1]); strcpy(dst.file,argv[2]); + fourier_init(&fourier,1); + fourier.type=DFT|FWD; + fourier.dim=2; + 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); - /* simple copy for testing by now ! */ - memcpy(dst.map,src.map,src.info.imagesize); + 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)); + if(mag==NULL) { + printf("unable to alloc mag memory\n"); + return -1; + } + + // copy the data + offy=0; + for(y=0;ymax) max=mag[offt]; + offt+=1; + } + } + + printf("found max: %f\n",max); + + if(max!=0) scale=(int)255/max; + else scale=0; + + if(scale!=0) { + printf("scaling image intensity: %d\n",scale); + offt=0; + for(y=0;y