#define convert(x, y) sqrt((double)((x)*(x) + (y)*(y))) #define D0 32.0 #define N0 4.0 /*************************************************************************** * Func: filter * * * * Desc: filters an array of complex data (assumes data is unordered) * * * * Params: complex_data - pointer to an array of complex data * * rows - number of rows in the image * * cols - number of cols in the image * ***************************************************************************/ void filter(complex_ptr complex_data, int rows, int cols) { unsigned long x, y; /* index for columns and rows */ unsigned long tempx, tempy; /* unordered indices */ int halfcols, halfrows; /* rows and cols divided by 2 */ unsigned long index; /* index into image */ double butterworth; /* value of filter function */ double coordinate; /* one-dimensional equivalent of x and y */ halfrows = rows / 2; halfcols = cols / 2; for(y=0; y= halfrows) tempy = y - halfrows; else tempy = y + halfrows; for(x=0; x= halfcols) tempx = x - halfcols; else tempx = x + halfcols; index = y * cols + x; coordinate = convert((tempx - halfrows), (tempy - halfcols)); butterworth = 1.0 / (1.0 + pow(( coordinate / D0), 2*N0)); complex_data[index].re *= butterworth; complex_data[index].im *= butterworth; } } }