Main Page   Namespace List   Compound List   File List   Namespace Members   Compound Members  

support.h File Reference

#include <errno.h>
#include <stdio.h>
#include <sstream>
#include <string>
#include "fftw3.h"
#include "msg_stream.h"

Go to the source code of this file.

Namespaces

namespace  FFT


Detailed Description


Copyright (c) 2004, Sylvain Paris and Francois Sillion
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

    * Redistributions of source code must retain the above copyright
    notice, this list of conditions and the following disclaimer.
    
    * Redistributions in binary form must reproduce the above
    copyright notice, this list of conditions and the following
    disclaimer in the documentation and/or other materials provided
    with the distribution.

    * Neither the name of ARTIS, GRAVIR-IMAG nor the names of its
    contributors may be used to endorse or promote products derived
    from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

This file contain code made by Sylvain Paris under supervision of François Sillion for his PhD work with ARTIS project. ARTIS is a research project in the GRAVIR/IMAG laboratory, a joint unit of CNRS, INPG, INRIA and UJF.

FFT::Support is the base class that performs the FFT transforms. A FFT::Support object has to be created for each domain size. For instance, to handle images 500x500 and 32x128, one has to create a FFT::Support(500,500) and FFT::Support(32,128).

A buffer object is provided to effciently manipulate the temporary variable. For instance, if one has to use several times the Fourier transform of an image, it is more efficient to apply the FFT once and then to use a buffer to store the result in a buffer than to compute the FFT each time. Most of the functions accept either a non-transformed function or a FFT buffer as input parameters.

The array class is assumed to provide the following functions: x_size(), y_size(), resize(unsigned int, unsigned int).

Here is a code example for the convolution f*g=h :

    // Initialization 
 
    FFT::Support::set_wisdom_file("wisdom.fftw");
    FFT::Support support(f.x_size(),f.y_size());

    // ################
    // ### FFT of f ###
    // ################

    // We need a temporary buffer.
    FFT::Support::buffer_type buffer = support.create_buffer();

    // Store f data in the fftw structures.
    support.load_space_data(f);
    
    // Compute the FFT.
    support.space_to_frequency();
    
    // Copy the result in a safe place.
    support.save_frequency_data_into_buffer(buffer);
    
    
    // ################
    // ### FFT of g ###
    // ################

    // Store g data in the fftw structures.    
    support.load_space_data(g);
    
    // Compute the FFT.
    support.space_to_frequency();



    
    // Multiplication "in place" in the frequency space.    
    support.multiply_frequency_data_by_buffer(buffer,true);


    

    // ###################
    // ### Inverse FFT ###
    // ###################
    
    // Compute inverse FFT transform.
    support.frequency_to_space();

    // Return data into the original structures    
    support.save_space_data(h);


    // Free the buffer memory.
    support.destroy_buffer(buffer);
Note that the convolution is already provided in convolution.h.


Generated on Thu Aug 19 15:55:51 2004 by doxygen1.2.18