/* Copyright (c) 2001 C. Grigorescu */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <tip.h> // Example program for the "FourierTransform" class. // // Usage: // test_fft <input_image> // int main(int argc, char *argv[]) { // Test for the correct number of arguments in the command line. if (argc != 2) { cout << "Usage: " << argv[0] << " <input_image>" << endl; exit(0); } // Read an image from the file specified by "argv[1]" and display it. FloatImage im0; im0.readImage(argv[1]); im0.showImage(); // Print some image statistics. cout << "Original image statistics" << endl; cout << " Min: " << im0.min() << endl; cout << " Max: " << im0.max() << endl; cout << " Avg: " << im0.avg() << endl; cout << " Std. dev.: " << im0.dev() << endl << endl; // Initialize the FourierTransform object with the input image. // The real part is initialized with the image, the imaginary part is 0. FourierTransform a(im0); // Perform the Fast Fourier Transform (FFT). a.fft(); // Display the magnitude and the phase. // parameters: 1 - display log of the values // 0 - display the values as they are a.showMagnitude(1); a.showPhase(0); // The real and the imaginary parts of the Fourier transform can be retrieved // with "getReal()" and "getImag()" member functions. FloatImage real, imag; real = a.getReal(); imag = a.getImag(); // Perform the inverse Fast Fourier Transform. a.ifft(); // The real and the imaginary parts can be obtained with "getReal()" and "getImag()" FloatImage real1, imag1; real1 = a.getReal(); imag1 = a.getImag(); // Display the result and statistics of the resulted image. real1.showImage(); cout << "FFT-IFFT image statistics" << endl; cout << " Min: " << real1.min() << endl; cout << " Max: " << real1.max() << endl; cout << " Avg: " << real1.avg() << endl; cout << " Std. dev.: " << real1.dev() << endl << endl; char l; cin >> l; // Close the magnitude and phase windows. a.closeWindows(); // Close the other windows. im0.closeWindow(); real.closeWindow(); imag.closeWindow(); real1.closeWindow(); imag1.closeWindow(); return(1); }