ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkGaborKernelFunction.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkGaborKernelFunction_h
00019 #define __itkGaborKernelFunction_h
00020 
00021 #include "itkKernelFunctionBase.h"
00022 #include <math.h>
00023 
00024 namespace itk
00025 {
00049 template< typename TRealValueType>
00050 class ITK_EXPORT GaborKernelFunction:public KernelFunctionBase<TRealValueType>
00051 {
00052 public:
00054   typedef GaborKernelFunction                Self;
00055   typedef KernelFunctionBase<TRealValueType> Superclass;
00056   typedef SmartPointer< Self >               Pointer;
00057 
00059   itkNewMacro(Self);
00060 
00062   itkTypeMacro(GaborKernelFunction, KernelFunctionBase);
00063 
00065   inline TRealValueType Evaluate(const TRealValueType & u) const
00066   {
00067     TRealValueType parameter = vnl_math_sqr(u / this->m_Sigma);
00068     TRealValueType envelope = vcl_exp(static_cast< TRealValueType >(-0.5) * parameter);
00069     TRealValueType phase = static_cast< TRealValueType >(2.0 * vnl_math::pi) * this->m_Frequency * u
00070                    + this->m_PhaseOffset;
00072 
00073     if ( this->m_CalculateImaginaryPart )
00074       {
00075       return envelope * vcl_sin(phase);
00076       }
00077     else
00078       {
00079       return envelope * vcl_cos(phase);
00080       }
00081   }
00082 
00083   itkSetMacro(Sigma, TRealValueType);
00084   itkGetConstMacro(Sigma, TRealValueType);
00085 
00086   itkSetMacro(Frequency, TRealValueType);
00087   itkGetConstMacro(Frequency, TRealValueType);
00088 
00089   itkSetMacro(PhaseOffset, TRealValueType);
00090   itkGetConstMacro(PhaseOffset, TRealValueType);
00091 
00092   itkSetMacro(CalculateImaginaryPart, bool);
00093   itkGetConstMacro(CalculateImaginaryPart, bool);
00094   itkBooleanMacro(CalculateImaginaryPart);
00095 protected:
00096   GaborKernelFunction()
00097     {
00098     this->m_CalculateImaginaryPart = false;
00099     this->m_Sigma = NumericTraits< TRealValueType >::One;
00100     this->m_Frequency = static_cast<TRealValueType>(0.4);
00101     this->m_PhaseOffset = NumericTraits< TRealValueType >::Zero;
00102     }
00103   ~GaborKernelFunction() {};
00104   void PrintSelf(std::ostream & os, Indent indent) const
00105     {
00106     Superclass::PrintSelf(os, indent);
00107 
00108     os << indent << "Sigma: " << this->GetSigma() << std::endl;
00109     os << indent << "Frequency: " << this->GetFrequency() << std::endl;
00110     os << indent << "PhaseOffset: " << this->GetPhaseOffset() << std::endl;
00111     os << indent << "CalculateImaginaryPart: " << this->GetCalculateImaginaryPart() << std::endl;
00112     }
00113 
00114 private:
00115   GaborKernelFunction(const Self &); //purposely not implemented
00116   void operator=(const Self &);      //purposely not implemented
00117 
00119   TRealValueType m_Sigma;
00120 
00122   TRealValueType m_Frequency;
00123 
00125   TRealValueType m_PhaseOffset;
00126 
00128   bool m_CalculateImaginaryPart;
00129 };
00130 } // end namespace itk
00131 
00132 #endif
00133