ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkGaborKernelFunction.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkGaborKernelFunction_h
19 #define __itkGaborKernelFunction_h
20 
21 #include "itkKernelFunctionBase.h"
22 #include <math.h>
23 
24 namespace itk
25 {
49 template< typename TRealValueType>
50 class ITK_EXPORT GaborKernelFunction:public KernelFunctionBase<TRealValueType>
51 {
52 public:
57 
59  itkNewMacro(Self);
60 
63 
65  inline TRealValueType Evaluate(const TRealValueType & u) const
66  {
67  TRealValueType parameter = vnl_math_sqr(u / this->m_Sigma);
68  TRealValueType envelope = vcl_exp(static_cast< TRealValueType >(-0.5) * parameter);
69  TRealValueType phase = static_cast< TRealValueType >(2.0 * vnl_math::pi) * this->m_Frequency * u
70  + this->m_PhaseOffset;
72 
73  if ( this->m_CalculateImaginaryPart )
74  {
75  return envelope * vcl_sin(phase);
76  }
77  else
78  {
79  return envelope * vcl_cos(phase);
80  }
81  }
82 
83  itkSetMacro(Sigma, TRealValueType);
84  itkGetConstMacro(Sigma, TRealValueType);
85 
86  itkSetMacro(Frequency, TRealValueType);
87  itkGetConstMacro(Frequency, TRealValueType);
88 
89  itkSetMacro(PhaseOffset, TRealValueType);
90  itkGetConstMacro(PhaseOffset, TRealValueType);
91 
92  itkSetMacro(CalculateImaginaryPart, bool);
93  itkGetConstMacro(CalculateImaginaryPart, bool);
94  itkBooleanMacro(CalculateImaginaryPart);
95 protected:
97  {
98  this->m_CalculateImaginaryPart = false;
100  this->m_Frequency = static_cast<TRealValueType>(0.4);
101  this->m_PhaseOffset = NumericTraits< TRealValueType >::Zero;
102  }
104  void PrintSelf(std::ostream & os, Indent indent) const
105  {
106  Superclass::PrintSelf(os, indent);
107 
108  os << indent << "Sigma: " << this->GetSigma() << std::endl;
109  os << indent << "Frequency: " << this->GetFrequency() << std::endl;
110  os << indent << "PhaseOffset: " << this->GetPhaseOffset() << std::endl;
111  os << indent << "CalculateImaginaryPart: " << this->GetCalculateImaginaryPart() << std::endl;
112  }
113 
114 private:
115  GaborKernelFunction(const Self &); //purposely not implemented
116  void operator=(const Self &); //purposely not implemented
117 
119  TRealValueType m_Sigma;
120 
122  TRealValueType m_Frequency;
123 
125  TRealValueType m_PhaseOffset;
126 
129 };
130 } // end namespace itk
131 
132 #endif
133