#include #include #include #include #include "project.h" int main(int argc, char **argv) { int n,m; fftw_plan transform; fftw_complex *image, *out; int smelly; char c; int i,j; double max = 0; double *value; //parse the input if (!(getchar() == 'P' && getchar() == '5')) { //pgm files start with "P5" fprintf(stderr,"Need pgm data from stdin\n"); return(EXIT_FAILURE); } NEXTLINE(); while ((c = getchar()) == '#') NEXTLINE(); //ignore comments ungetc(c,stdin); scanf("%i%i%i",&n,&m,&smelly); //parse the important numbers NEXTLINE(); fprintf(stderr,"%ix%i image read. %i - should be 255 :-)\n",n,m,smelly); //prepare the Row-major Format 2-D arrays image = fftw_malloc(sizeof(fftw_complex) * n*m); out = fftw_malloc(sizeof(fftw_complex) * n*m); value = (double *)malloc(sizeof(double)*n*m); //fill up the input array using the pgm picture for (j=0; j max ? value[j*n+i] : max; } } //output a pgm of the fourier transform PGM_HEADER(n,m) for (j=0; j