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.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 #include <ICLMath/FFTUtils.h> 00033 #include <ICLCore/ImgBase.h> 00034 #include <ICLCore/Img.h> 00035 #include <ICLFilter/UnaryOp.h> 00036 #include <cmath> 00037 00038 namespace icl{ 00039 namespace filter{ 00040 00041 00116 class FFTOp : public UnaryOp{ 00117 00118 private: 00120 class Data; 00121 00123 Data *m_data; 00124 00125 //Applies fft/dft on all channel of sourceimage. 00130 template<class SrcT, class DstT> 00131 void apply_internal(const core::Img<SrcT> &src, core::Img<DstT> &dst, 00132 math::DynMatrix<std::complex<DstT> > &buf, 00133 math::DynMatrix<std::complex<DstT> > &dstBuf); 00134 00135 //Adapts sourceimage before fft/dft computation. 00139 template<class T> 00140 const core::Img<T> *adapt_source(const core::Img<T> *src); 00141 00142 //Applies an inplace fftshift after computation of the fft (if possible). 00145 template<typename T> 00146 void apply_inplace_fftshift(math::DynMatrix<T> &m); 00147 00148 public: 00150 00151 enum SizeAdaptionMode{ 00152 NO_SCALE, 00153 PAD_ZERO, 00154 PAD_COPY, 00155 PAD_MIRROR, 00156 SCALE_UP, 00157 SCALE_DOWN 00158 }; 00159 00161 00162 enum ResultMode{ 00163 TWO_CHANNEL_COMPLEX, 00164 IMAG_ONLY, 00165 REAL_ONLY, 00166 POWER_SPECTRUM, 00167 LOG_POWER_SPECTRUM, 00168 MAGNITUDE_ONLY, 00169 PHASE_ONLY, 00170 TWO_CHANNEL_MAGNITUDE_PHASE 00171 }; 00172 00174 00179 FFTOp(ResultMode rm=LOG_POWER_SPECTRUM, SizeAdaptionMode sam=NO_SCALE, 00180 bool fftshift=true,bool forceDFT=false); 00181 00183 ~FFTOp(); 00184 00186 00187 void setResultMode(ResultMode rm); 00188 00190 00191 int getResultMode(); 00192 00194 00195 void setSizeAdaptionMode(SizeAdaptionMode sam); 00196 00198 00199 int getSizeAdaptionMode(); 00200 00202 00203 bool getForceDFT(); 00204 00206 00207 void setForceDFT(bool pForceDFT); 00208 00210 00211 void setFFTShift(bool pFFTShift); 00212 00214 00215 bool getFFTShift(); 00216 00218 00221 virtual void apply(const core::ImgBase *src, core::ImgBase **dst); 00222 00224 using UnaryOp::apply; 00225 }; 00226 } // namespace filter 00227 } 00228