IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 29, 2004, 7:40:01 PM (22 years ago)
Author:
Paul Price
Message:

Major hack of the FFT APIs, incorporating Nick's comments: Defined a
FFT type, on which all the FFT operations act. This insulates us from
the details of the implementation (e.g., FFTW requires a "plan";
different FFT libraries store the transformed data differently).
Added the functionality Nick suggested (filtering, cross-correlation).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/archive/pslib/include/psFFT.h

    r257 r314  
    11#if !defined(PS_FFT_H)
    22#define PS_FFT_H
     3
     4#include <fftw3.h>
    35
    46/** \file psFFT.h
     
    1214 */
    1315
    14 /** Return Fourier Transform of an array */
    15 psComplexArray *
    16 psRealFFT(psComplexArray *restrict out, //!< Output array to be returned; may be NULL
    17           const psFloatArray *restrict myArray //!< Input array
     16/** Details on FFT implementation (private).  Example shown is for FFTW */
     17typedef struct {
     18    fftw_plan plan;                     //!< FFTW plan on how to do the FFT
     19    char *filename;                     //!< File name for FFTW plan
     20} p_psFFTDetails;
     21
     22/** Fast Fourier Transform */
     23typedef struct {
     24    p_psFFTDetails *details;            //!< Details on FFT implementation (private)
     25    int nx, ny;                         //!< Size in x and y
     26    float **real;                       //!< Data in real space
     27    void *fourier;                      //!< Data in fourier space; implementation dependent
     28} psFFT;
     29
     30/** Constructor */
     31psFFT *
     32psFFTAlloc(psImage *image               //!< Image to transform
     33           );
     34
     35/** Constructor for 1D case */
     36psFFT *
     37psFFTAlloc1D(const psFloatArray *arr    //!< Array to transform
     38             );
     39
     40/** Destructor. Returns the data in the real space as an image. */
     41psImage *
     42psFFTFree(psImage *out,                 //!< Image to write the data to, or NULL
     43          psFFT *restrict fft           //!< FFT to destroy
    1844          );
    1945
    20 /** Return [inverse?] Fourier Transform of a complex array.  May NOT be done in-place (restrict-ed) */
    21 psComplexArray *
    22 psComplexFFT(psComplexArray *restrict out, //!< Output array to be returned; may be NULL
    23              const psComplexArray *restrict myArray, //!< Input array
    24              int sign                   //!< +1 or -1 to indicate direction of FT
    25              );
     46/** Forward FFT: from real to fourier space */
     47psFFT *
     48psFFTForwardTransform(psFFT *fft        //!< FFT to apply (input and output)
     49                      );
    2650
    27 /** Return Power spectrum of a array */
    28 psFloatArray *
    29 psPowerSpec(psFloatArray *restrict out, //!< Output array to be returned
    30             const psFloatArray *restrict myArray //!< Input array
     51/** Reverse FFT: from fourier to real space */
     52psFFT *
     53psFFTReverseTransform(psFFT *fft        //!< FFT to apply (input and output)
     54                      );
     55
     56/** Apply filter function in fourier space */
     57psFFT *
     58psFFTFilter(psFFT *fft,                 //!< FFT to use (input and output)
     59            float (*filterFunc)(int kx, int ky) //!< External filter function
    3160            );
     61
     62/** Apply complex filter function */
     63psFFT *
     64psFFTFilterComplex(psFFT *fft,          //!< FFT to use (input and output)
     65                   float (*realFilterFunc)(int kx, int ky), //!< External filter function, real part
     66                   float (*imagFilterFunc)(int kx, int ky) //!< External filter function, imaginary part
     67                   );
     68
     69/** Calculate cross-correlation function */
     70psFFT *
     71psFFTCrossCorrelate(psFFT *out          //!< Output FFT (or NULL)
     72                    const psFFT *fft1, const psFFT *fft2 //!< FFTs to use in cross-correlation
     73                    );
     74
     75/** Calculate power spectrum */
     76psFFT *
     77psFFTPowerSpec(psFFT *fft               //!< FFT to use (input and output)
     78               );
     79
     80/** Multiply two Fourier transforms, as for convolution */
     81psFFT *
     82psFFTMultiplyFT(psFFT *out,             //!< Output FFT (or NULL)
     83                const psFFT *fft1, const psFFT *fft2 //!< FFTs to multiply
     84                );
     85
     86/* Convert the real data in the FFT struct to an image again */
     87psImage *
     88psFFTGetImage(psImage *out,             //!< Image to write to (or NULL)
     89              const psFFT *fft          //!< FFT to get image from
     90              );
     91
     92/** Convert the Fourier transform data in the FFT struct to an image of complex numbers */
     93psImage *
     94psFFTGetFT(psImage *out,                //!< Image to write to (or NULL)
     95           const psFFT *fft             //!< FFT to get Fourier transform from
     96           );
    3297
    3398/* \} */ // End of MathGroup Functions
    3499
    35100#endif
     101
     102
Note: See TracChangeset for help on using the changeset viewer.