Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
FFTUtils.h
Go to the documentation of this file.
00001 /********************************************************************
00002 **                Image Component Library (ICL)                    **
00003 **                                                                 **
00004 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld          **
00005 **                         Neuroinformatics Group                  **
00006 ** Website: www.iclcv.org and                                      **
00007 **          http://opensource.cit-ec.de/projects/icl               **
00008 **                                                                 **
00009 ** File   : ICLMath/src/ICLMath/FFTUtils.h                         **
00010 ** Module : ICLMath                                                **
00011 ** Authors: Christian Groszewski, Christof Elbrechter              **
00012 **                                                                 **
00013 **                                                                 **
00014 ** GNU LESSER GENERAL PUBLIC LICENSE                               **
00015 ** This file may be used under the terms of the GNU Lesser General **
00016 ** Public License version 3.0 as published by the                  **
00017 **                                                                 **
00018 ** Free Software Foundation and appearing in the file LICENSE.GPL  **
00019 ** included in the packaging of this file.  Please review the      **
00020 ** following information to ensure the license requirements will   **
00021 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt                **
00022 **                                                                 **
00023 ** The development of this software was supported by the           **
00024 ** Excellence Cluster EXC 277 Cognitive Interaction Technology.    **
00025 ** The Excellence Cluster EXC 277 is a grant of the Deutsche       **
00026 ** Forschungsgemeinschaft (DFG) in the context of the German       **
00027 ** Excellence Initiative.                                          **
00028 **                                                                 **
00029 ********************************************************************/
00030 
00031 #pragma once
00032 
00033 #include <complex>
00034 #include <ICLUtils/BasicTypes.h>
00035 #include <ICLMath/DynMatrix.h>
00036 #include <ICLMath/FFTException.h>
00037 #include <string.h>
00038 
00039 using namespace icl::utils;
00040 
00041 namespace icl{
00042   namespace math{
00043   
00044   namespace fft{
00045   
00047   static const double FFT_2_PI = 2.0*3.1415926535897932384626433832795288419716939937510;
00048   
00050   static const double FFT_PI = 3.1415926535897932384626433832795288419716939937510;
00051   
00053   static const double FFT_PI_HALF = 1.5707963267948966192313216916397644209858469968755;
00054   
00056 
00066   template<typename T1,typename T2>
00067   std::complex<T2>* fft(unsigned int n, const T1* data);
00068   
00070 
00080   template<typename T1, typename T2>
00081   DynMatrix<std::complex<T2> >&  fft2D_cpp(const DynMatrix<T1> &src,
00082                 DynMatrix<std::complex<T2> > &dst,DynMatrix<std::complex<T2> > &buf);
00083   
00085 
00095   template<typename T1, typename T2>
00096   DynMatrix<std::complex<T2> >& fft2D(const DynMatrix<T1> &src,DynMatrix<std::complex<T2> > &dst,
00097                 DynMatrix<std::complex<T2> > &buf);
00098   
00100 
00108   template<typename T1,typename T2>
00109   std::complex<T2>* dft(unsigned int n, T1 *matrix);
00110   
00112 
00121   template<typename T1,typename T2>
00122   DynMatrix<std::complex<T2> >&  dft2D(DynMatrix<T1> &src,
00123                 DynMatrix<std::complex<T2> >& dst,DynMatrix<std::complex<T2> >&buf);
00124   
00126 
00133   template<typename T1,typename T2>
00134   std::complex<T2>* ifft_cpp(unsigned int n, const T1* matrix);
00135   
00137 
00145   template<typename T1, typename T2>
00146   DynMatrix<std::complex<T2> >&  ifft2D_cpp(const DynMatrix<T1>& src,
00147                 DynMatrix<std::complex<T2> > &dst,DynMatrix<std::complex<T2> > &buf);
00148   
00150 
00159   template<typename T1, typename T2>
00160   DynMatrix<std::complex<T2> >&   ifft2D(const DynMatrix<T1> &src,DynMatrix<std::complex<T2> > &dst,
00161                 DynMatrix<std::complex<T2> > &buf);
00162   
00164 
00169   template<typename T1,typename T2>
00170   std::complex<T2>* idft(unsigned int n, T1 *matrix);
00171   
00173 
00180   template<typename T1,typename T2>
00181   DynMatrix<std::complex<T2> > &idft2D(DynMatrix<T1> &src, DynMatrix<std::complex<T2> > &dst,
00182                 DynMatrix<std::complex<T2> > &buf);
00183   
00185 
00190   template<typename T>
00191   DynMatrix<T>& fftshift(DynMatrix<T> &src,DynMatrix<T> &dst) throw (InvalidMatrixDimensionException);
00192   
00194 
00199   template<typename T>
00200   DynMatrix<T>& ifftshift(DynMatrix<T> &src,DynMatrix<T> &dst) throw (InvalidMatrixDimensionException);
00201   
00203 
00208   template<typename T>
00209   DynMatrix<T>& powerspectrum(const DynMatrix<std::complex<T> > &src,DynMatrix<T> &dst);
00210   
00212 
00217   template<typename T>
00218   DynMatrix<T>& logpowerspectrum(const DynMatrix<std::complex<T> > &src,DynMatrix<T> &dst);
00219   
00221 
00228   template<typename T>
00229   DynMatrix<T> &makeborder(const DynMatrix<T> &src,DynMatrix<T> &dst, T borderFill);
00230   
00232 
00238   template<typename T>
00239   DynMatrix<T> &mirrorOnCenter(const DynMatrix<T> &src, DynMatrix<T> &dst);
00240   
00242 
00249   template<typename T>
00250   DynMatrix<T> &continueMatrixToPowerOf2(const DynMatrix<T> &src, DynMatrix<T> &dst);
00251   
00252   
00254   int nextPowerOf2(int n);
00255   
00257   int priorPowerOf2(int n);
00258   
00260 
00266   template<typename T>
00267   void split_complex(const DynMatrix<std::complex<T> > &src, DynMatrix<T> &real, DynMatrix<T> &img);
00268   
00270 
00275   template<typename T1,typename T2>
00276   DynMatrix<T2> &imagpart(const DynMatrix<std::complex<T1> > &src,DynMatrix<T2> &dst);
00277   
00279 
00284   template<typename T1,typename T2>
00285   DynMatrix<T2> &realpart(const DynMatrix<std::complex<T1> > &src, DynMatrix<T2> &dst);
00286   
00288 
00293   template<typename T1,typename T2>
00294   DynMatrix<T2>& magnitude(const DynMatrix<std::complex<T1> > &src, DynMatrix<T2> &dst);
00295   
00297 
00302   template<typename T1,typename T2>
00303   DynMatrix<T2>& phase(const DynMatrix<std::complex<T1> > &src, DynMatrix<T2> &dst);
00304   
00306 
00311   template<typename T>
00312   void split_magnitude_phase(const DynMatrix<std::complex<T> > &src, DynMatrix<T> &mag, DynMatrix<T> &phase);
00313   
00315 
00319   template<typename T1,typename T2>
00320   DynMatrix<std::complex<T2> > &joinComplex(const DynMatrix<T1> &real, const DynMatrix<T1> &im,DynMatrix<std::complex<T2> > &dst);
00321   
00322   } // namespace math
00323 }
00324 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines