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/doc/pslib/psLibSDRS.tex

    r313 r314  
    1 %%% $Id: psLibSDRS.tex,v 1.13 2004-03-29 22:13:13 price Exp $
     1%%% $Id: psLibSDRS.tex,v 1.14 2004-03-30 05:40:01 price Exp $
    22\documentclass[panstarrs]{panstarrs}
    33%\documentclass[panstarrs]{panstarrs}
     
    14371437
    14381438We require the ability to calculate the (fast) fourier transforms of
    1439 both floating-point and complex floating-point type arrays, as well as
    1440 the power spectrum.  The APIs are:
    1441 
    1442 \begin{verbatim}
    1443 /** Return Fourier Transform of an array */
    1444 psComplexArray *
    1445 psRealFFT(psComplexArray *restrict out, //!< Output array to be returned; may be NULL
    1446           const psFloatArray *restrict myArray //!< Input array
    1447           );
    1448 \end{verbatim}
    1449 
    1450 \begin{verbatim}
    1451 /** Return [inverse?] Fourier Transform of a complex array.  May NOT be done in-place (restrict-ed) */
    1452 psComplexArray *
    1453 psComplexFFT(psComplexArray *restrict out, //!< Output array to be returned; may be NULL
    1454              const psComplexArray *restrict myArray, //!< Input array
    1455              int sign                   //!< +1 or -1 to indicate direction of FT
    1456              );
    1457 \end{verbatim}
    1458 
    1459 \begin{verbatim}
    1460 /** Return Power spectrum of a array */
    1461 psFloatArray *
    1462 psPowerSpec(psFloatArray *restrict out, //!< Output array to be returned
    1463             const psFloatArray *restrict myArray //!< Input array
    1464             );
     1439floating-point two-dimensional arrays (including one-dimensional
     1440arrays as a limiting case), and use these to perform filtering, and
     1441calculate the power spectrum and cross-correlation.  We expect that
     1442these will be implemented through wrapping an external library.  We
     1443define a FFT type:
     1444
     1445\begin{verbatim}
     1446/** Fast Fourier Transform */
     1447typedef struct {
     1448    p_psFFTDetails *details;            //!< Details on FFT implementation (private)
     1449    int nx, ny;                         //!< Size in x and y
     1450    float **real;                       //!< Data in real space
     1451    void *fourier;                      //!< Data in fourier space; implementation dependent
     1452} psFFT;
     1453\end{verbatim}
     1454
     1455The \code{p_psFFTDetails *details} entry allows us to wrap the
     1456external library in the event that it carries information around from
     1457one transform to the next (as is the case for FFTW).  The intent is
     1458that every function that employs a FFT will act on a \code{psFFT}.  A
     1459user will create a \code{psFFT} by stuffing it with the real data,
     1460perform operations in Fourier space using the \code{psFFT}, and then
     1461extract the output as an image when done.
     1462
     1463We specify two constructors --- one for use with images, and the other
     1464for use with a one-dimensional array.  The destructor returns an image
     1465that includes the real space data.
     1466
     1467\begin{verbatim}
     1468/** Constructor */
     1469psFFT *
     1470psFFTAlloc(psImage *image               //!< Image to transform
     1471           );
     1472
     1473/** Constructor for 1D case */
     1474psFFT *
     1475psFFTAlloc1D(const psFloatArray *arr    //!< Array to transform
     1476             );
     1477
     1478/** Destructor. Returns the data in the real space as an image. */
     1479psImage *
     1480psFFTFree(psImage *out,                 //!< Image to write the data to, or NULL
     1481          psFFT *restrict fft           //!< FFT to destroy
     1482          );
     1483\end{verbatim}
     1484
     1485The forward and reverse Fourier transforms may be calculated:
     1486
     1487\begin{verbatim}
     1488/** Forward FFT: from real to fourier space */
     1489psFFT *
     1490psFFTForwardTransform(psFFT *fft        //!< FFT to apply
     1491                      );
     1492
     1493/** Reverse FFT: from fourier to real space */
     1494psFFT *
     1495psFFTReverseTransform(psFFT *fft        //!< FFT to apply
     1496                      );
     1497\end{verbatim}
     1498
     1499The data in Fourier space may be filtered using functions that return
     1500a multiplicative factor for a given position in Fourier space:
     1501
     1502\begin{verbatim}
     1503/** Apply filter function in fourier space */
     1504psFFT *
     1505psFFTFilter(psFFT *fft,                 //!< FFT to use (input and output)
     1506            float (*filterFunc)(int kx, int ky) //!< External filter function
     1507            );
     1508
     1509/** Apply complex filter function */
     1510psFFT *
     1511psFFTFilterComplex(psFFT *fft,          //!< FFT to use (input and output)
     1512                   float (*realFilterFunc)(int kx, int ky), //!< External filter function, real part
     1513                   float (*imagFilterFunc)(int kx, int ky) //!< External filter function, imaginary part
     1514                   );
     1515\end{verbatim}
     1516
     1517The cross-correlation function may be calculated from two Fourier transforms,
     1518and returns a new \code{psFFT}:
     1519
     1520\begin{verbatim}
     1521/** Calculate cross-correlation function */
     1522psFFT *
     1523psFFTCrossCorrelate(psFFT *out          //!< Output FFT (or NULL)
     1524                    psFFT *fft1, psFFT *fft2 //!< FFTs to use in cross-correlation
     1525                    );
     1526\end{verbatim}
     1527
     1528The power spectrum is calculated from the Fourier transform:
     1529
     1530\begin{verbatim}
     1531/** Calculate power spectrum */
     1532psFFT *
     1533psFFTPowerSpec(psFFT *fft               //!< FFT to use (input and output)
     1534               );
     1535\end{verbatim}
     1536
     1537In convolution, two Fourier transforms are multiplied.
     1538
     1539\begin{verbatim}
     1540/** Multiply two Fourier transforms, as for convolution */
     1541psFFT *
     1542psFFTMultiplyFT(psFFT *out,             //!< Output FFT (or NULL)
     1543                const psFFT *fft1, const psFFT *fft2 //!< FFTs to multiply
     1544                );
     1545\end{verbatim}
     1546
     1547And finally, the user may extract both the real data and the complex
     1548Fourier space data (without needing to destroy the \code{psFFT}).
     1549
     1550\begin{verbatim}
     1551/* Convert the real data in the FFT struct to an image again */
     1552psImage *
     1553psFFTGetImage(psImage *out,             //!< Image to write to (or NULL)
     1554              const psFFT *fft          //!< FFT to get image from
     1555              );
     1556
     1557/** Convert the Fourier transform data in the FFT struct to an image of complex numbers */
     1558psImage *
     1559psFFTGetFT(psImage *out,                //!< Image to write to (or NULL)
     1560           const psFFT *fft             //!< FFT to get Fourier transform from
     1561           );
    14651562\end{verbatim}
    14661563
Note: See TracChangeset for help on using the changeset viewer.