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 : ICLFilter/src/ICLFilter/FFTOp.h ** 00010 ** Module : ICLFilter ** 00011 ** Authors: 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 <ICLMath/FFTUtils.h> 00035 #include <ICLCore/Img.h> 00036 #include <ICLFilter/UnaryOp.h> 00037 #include <cmath> 00038 00039 namespace icl{ 00040 namespace filter{ 00041 00042 00117 class ICLFilter_API FFTOp : public UnaryOp{ 00118 00119 private: 00121 class Data; 00122 00124 Data *m_data; 00125 00126 //Applies fft/dft on all channel of sourceimage. 00131 template<class SrcT, class DstT> 00132 void apply_internal(const core::Img<SrcT> &src, core::Img<DstT> &dst, 00133 math::DynMatrix<std::complex<DstT> > &buf, 00134 math::DynMatrix<std::complex<DstT> > &dstBuf); 00135 00136 //Adapts sourceimage before fft/dft computation. 00140 template<class T> 00141 const core::Img<T> *adapt_source(const core::Img<T> *src); 00142 00143 //Applies an inplace fftshift after computation of the fft (if possible). 00146 template<typename T> 00147 void apply_inplace_fftshift(math::DynMatrix<T> &m); 00148 00149 public: 00151 00152 enum SizeAdaptionMode{ 00153 NO_SCALE, 00154 PAD_ZERO, 00155 PAD_COPY, 00156 PAD_MIRROR, 00157 SCALE_UP, 00158 SCALE_DOWN 00159 }; 00160 00162 00163 enum ResultMode{ 00164 TWO_CHANNEL_COMPLEX, 00165 IMAG_ONLY, 00166 REAL_ONLY, 00167 POWER_SPECTRUM, 00168 LOG_POWER_SPECTRUM, 00169 MAGNITUDE_ONLY, 00170 PHASE_ONLY, 00171 TWO_CHANNEL_MAGNITUDE_PHASE 00172 }; 00173 00175 00180 FFTOp(ResultMode rm=LOG_POWER_SPECTRUM, SizeAdaptionMode sam=NO_SCALE, 00181 bool fftshift=true,bool forceDFT=false); 00182 00184 ~FFTOp(); 00185 00187 00188 void setResultMode(ResultMode rm); 00189 00191 00192 int getResultMode(); 00193 00195 00196 void setSizeAdaptionMode(SizeAdaptionMode sam); 00197 00199 00200 int getSizeAdaptionMode(); 00201 00203 00204 bool getForceDFT(); 00205 00207 00208 void setForceDFT(bool pForceDFT); 00209 00211 00212 void setFFTShift(bool pFFTShift); 00213 00215 00216 bool getFFTShift(); 00217 00219 00222 virtual void apply(const core::ImgBase *src, core::ImgBase **dst); 00223 00225 using UnaryOp::apply; 00226 }; 00227 } // namespace filter 00228 } 00229