Image Component Library (ICL)
|
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.LGPL ** 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 <ICLUtils/CompatMacros.h> 00034 #include <ICLUtils/BasicTypes.h> 00035 #include <ICLMath/DynMatrix.h> 00036 #include <ICLMath/FFTException.h> 00037 #include <string.h> 00038 #include <complex> 00039 00040 using namespace icl::utils; 00041 00042 namespace icl{ 00043 namespace math{ 00044 00045 namespace fft{ 00046 00048 static const double FFT_2_PI = 2.0*3.1415926535897932384626433832795288419716939937510; 00049 00051 static const double FFT_PI = 3.1415926535897932384626433832795288419716939937510; 00052 00054 static const double FFT_PI_HALF = 1.5707963267948966192313216916397644209858469968755; 00055 00057 00067 template<typename T1,typename T2> ICLMath_IMP 00068 std::complex<T2>* fft(unsigned int n, const T1* data); 00069 00071 00081 template<typename T1, typename T2> ICLMath_IMP 00082 DynMatrix<std::complex<T2> >& fft2D_cpp(const DynMatrix<T1> &src, 00083 DynMatrix<std::complex<T2> > &dst,DynMatrix<std::complex<T2> > &buf); 00084 00086 00096 template<typename T1, typename T2> ICLMath_IMP 00097 DynMatrix<std::complex<T2> >& fft2D(const DynMatrix<T1> &src, DynMatrix<std::complex<T2> > &dst, 00098 DynMatrix<std::complex<T2> > &buf); 00099 00101 00109 template<typename T1, typename T2> ICLMath_IMP 00110 std::complex<T2>* dft(unsigned int n, T1 *matrix); 00111 00113 00122 template<typename T1, typename T2> ICLMath_IMP 00123 DynMatrix<std::complex<T2> >& dft2D(DynMatrix<T1> &src, 00124 DynMatrix<std::complex<T2> >& dst,DynMatrix<std::complex<T2> >&buf); 00125 00127 00134 template<typename T1, typename T2> ICLMath_IMP 00135 std::complex<T2>* ifft_cpp(unsigned int n, const T1* matrix); 00136 00138 00146 template<typename T1, typename T2> ICLMath_IMP 00147 DynMatrix<std::complex<T2> >& ifft2D_cpp(const DynMatrix<T1>& src, 00148 DynMatrix<std::complex<T2> > &dst,DynMatrix<std::complex<T2> > &buf); 00149 00151 00160 template<typename T1, typename T2> ICLMath_IMP 00161 DynMatrix<std::complex<T2> >& ifft2D(const DynMatrix<T1> &src, DynMatrix<std::complex<T2> > &dst, 00162 DynMatrix<std::complex<T2> > &buf); 00163 00165 00170 template<typename T1, typename T2> ICLMath_IMP 00171 std::complex<T2>* idft(unsigned int n, T1 *matrix); 00172 00174 00181 template<typename T1, typename T2> ICLMath_IMP 00182 DynMatrix<std::complex<T2> > &idft2D(DynMatrix<T1> &src, DynMatrix<std::complex<T2> > &dst, 00183 DynMatrix<std::complex<T2> > &buf); 00184 00186 00191 template<typename T> ICLMath_IMP 00192 DynMatrix<T>& fftshift(DynMatrix<T> &src, DynMatrix<T> &dst) throw (InvalidMatrixDimensionException); 00193 00195 00200 template<typename T> ICLMath_IMP 00201 DynMatrix<T>& ifftshift(DynMatrix<T> &src, DynMatrix<T> &dst) throw (InvalidMatrixDimensionException); 00202 00204 00209 template<typename T> ICLMath_IMP 00210 DynMatrix<T>& powerspectrum(const DynMatrix<std::complex<T> > &src, DynMatrix<T> &dst); 00211 00213 00218 template<typename T> ICLMath_IMP 00219 DynMatrix<T>& logpowerspectrum(const DynMatrix<std::complex<T> > &src, DynMatrix<T> &dst); 00220 00222 00229 template<typename T> ICLMath_IMP 00230 DynMatrix<T> &makeborder(const DynMatrix<T> &src, DynMatrix<T> &dst, T borderFill); 00231 00233 00239 template<typename T> ICLMath_IMP 00240 DynMatrix<T> &mirrorOnCenter(const DynMatrix<T> &src, DynMatrix<T> &dst); 00241 00243 00250 template<typename T> ICLMath_IMP 00251 DynMatrix<T> &continueMatrixToPowerOf2(const DynMatrix<T> &src, DynMatrix<T> &dst); 00252 00253 00255 ICLMath_API int nextPowerOf2(int n); 00256 00258 ICLMath_API int priorPowerOf2(int n); 00259 00261 00267 template<typename T> ICLMath_IMP 00268 void split_complex(const DynMatrix<std::complex<T> > &src, DynMatrix<T> &real, DynMatrix<T> &img); 00269 00271 00276 template<typename T1, typename T2> ICLMath_IMP 00277 DynMatrix<T2> &imagpart(const DynMatrix<std::complex<T1> > &src, DynMatrix<T2> &dst); 00278 00280 00285 template<typename T1, typename T2> ICLMath_IMP 00286 DynMatrix<T2> &realpart(const DynMatrix<std::complex<T1> > &src, DynMatrix<T2> &dst); 00287 00289 00294 template<typename T1, typename T2> ICLMath_IMP 00295 DynMatrix<T2>& magnitude(const DynMatrix<std::complex<T1> > &src, DynMatrix<T2> &dst); 00296 00298 00303 template<typename T1, typename T2> ICLMath_IMP 00304 DynMatrix<T2>& phase(const DynMatrix<std::complex<T1> > &src, DynMatrix<T2> &dst); 00305 00307 00312 template<typename T> ICLMath_IMP 00313 void split_magnitude_phase(const DynMatrix<std::complex<T> > &src, DynMatrix<T> &mag, DynMatrix<T> &phase); 00314 00316 00320 template<typename T1, typename T2> ICLMath_IMP 00321 DynMatrix<std::complex<T2> > &joinComplex(const DynMatrix<T1> &real, const DynMatrix<T1> &im, DynMatrix<std::complex<T2> > &dst); 00322 00323 } // namespace math 00324 } 00325 }