ITK  4.9.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 <cmath>
23 
24 namespace itk
25 {
49 template< typename TRealValueType>
50 class GaborKernelFunction:public KernelFunctionBase<TRealValueType>
51 {
52 public:
57 
59  itkNewMacro(Self);
60 
63 
65  inline TRealValueType Evaluate(const TRealValueType & u) const ITK_OVERRIDE
66  {
67  TRealValueType parameter = vnl_math_sqr(u / this->m_Sigma);
68  TRealValueType envelope = std::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 * std::sin(phase);
76  }
77  else
78  {
79  return envelope * std::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 
96 protected:
98  {
99  this->m_CalculateImaginaryPart = false;
101  this->m_Frequency = static_cast<TRealValueType>(0.4);
103  }
105  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE
106  {
107  Superclass::PrintSelf(os, indent);
108 
109  os << indent << "Sigma: " << this->GetSigma() << std::endl;
110  os << indent << "Frequency: " << this->GetFrequency() << std::endl;
111  os << indent << "PhaseOffset: " << this->GetPhaseOffset() << std::endl;
112  os << indent << "CalculateImaginaryPart: " << this->GetCalculateImaginaryPart() << std::endl;
113  }
114 
115 private:
116  GaborKernelFunction(const Self &) ITK_DELETE_FUNCTION;
117  void operator=(const Self &) ITK_DELETE_FUNCTION;
118 
120  TRealValueType m_Sigma;
121 
123  TRealValueType m_Frequency;
124 
126  TRealValueType m_PhaseOffset;
127 
130 };
131 } // end namespace itk
132 
133 #endif
Gabor kernel used for various computer vision tasks.
SmartPointer< Self > Pointer
void PrintSelf(std::ostream &os, Indent indent) const override
static const double pi
Definition: itkMath.h:57
virtual TRealValueType GetSigma() const
Kernel used for density estimation and nonparameteric regression.
KernelFunctionBase< TRealValueType > Superclass
virtual TRealValueType GetFrequency() const
TRealValueType Evaluate(const TRealValueType &u) const override
virtual bool GetCalculateImaginaryPart() const
virtual TRealValueType GetPhaseOffset() const
virtual void PrintSelf(std::ostream &os, Indent indent) const override
Control indentation during Print() invocation.
Definition: itkIndent.h:49