/* FFT2fltr_Low.c */ #include #include #include #include "mypgm.h" #include "FFT1.h" #include "FFT2.h" void lowpass_filtering( ) { int i, j; int M; double max, radius; printf("\nLowpass filtering is applied to FFT coefficients.\n"); printf("Total frequency range is 0 - %d.\n", num_of_data/2); while (1) { printf("Enter maximum frequency : "); scanf("%d", &M); if (0 < M && M <= num_of_data/2) break; printf("\nOutside the range!\n"); } max = pow(M, 2); for (j = 0; j < num_of_data; j++) { for (i = 0; i < num_of_data; i++) { radius = pow(i - num_of_data/2, 2) + pow(j - num_of_data/2, 2); if (radius > max) { data[j][i] = 0.0; jdata[j][i] = 0.0; } } } } main( ) { load_image_data( ); /* Input image load */ make_original_data( ); /* FFT arrays generation */ FFT2(1); /* 2-d FFT */ origin_centered_FFT(); /* FFT rearrangement */ lowpass_filtering( ); /* Lowpass filtering */ origin_centered_FFT(); /* FFT rearrangement */ FFT2(-1); /* 2-d inverse FFT */ make_output_image_enhanced( ); /* Enhanced image generation after IFFT */ save_image_data( ); /* Output image save */ return 0; }