ITK  4.13.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  TRealValueType Evaluate(const TRealValueType & u) const ITK_OVERRIDE
66  {
67  TRealValueType parameter = itk::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 * itk::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 
84  itkSetMacro(Sigma, TRealValueType);
85  itkGetConstMacro(Sigma, TRealValueType);
87 
89  itkSetMacro(Frequency, TRealValueType);
90  itkGetConstMacro(Frequency, TRealValueType);
92 
94  itkSetMacro(PhaseOffset, TRealValueType);
95  itkGetConstMacro(PhaseOffset, TRealValueType);
97 
100  itkSetMacro(CalculateImaginaryPart, bool);
101  itkGetConstMacro(CalculateImaginaryPart, bool);
102  itkBooleanMacro(CalculateImaginaryPart);
104 
105 protected:
107  {
108  this->m_CalculateImaginaryPart = false;
110  this->m_Frequency = static_cast<TRealValueType>(0.4);
112  }
113  ~GaborKernelFunction() ITK_OVERRIDE {};
114  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE
115  {
116  Superclass::PrintSelf(os, indent);
117 
118  os << indent << "Sigma: " << this->GetSigma() << std::endl;
119  os << indent << "Frequency: " << this->GetFrequency() << std::endl;
120  os << indent << "PhaseOffset: " << this->GetPhaseOffset() << std::endl;
121  os << indent << "CalculateImaginaryPart: " << this->GetCalculateImaginaryPart() << std::endl;
122  }
123 
124 private:
125  ITK_DISALLOW_COPY_AND_ASSIGN(GaborKernelFunction);
126 
127  TRealValueType m_Sigma;
128 
129  TRealValueType m_Frequency;
130 
131  TRealValueType m_PhaseOffset;
132 
134 };
135 } // end namespace itk
136 
137 #endif
Gabor kernel used for various computer vision tasks.
SmartPointer< Self > Pointer
void PrintSelf(std::ostream &os, Indent indent) const override
static ITK_CONSTEXPR_VAR double pi
Definition: itkMath.h:66
virtual TRealValueType GetSigma() const
Kernel used for density estimation and nonparameteric regression.
bool sqr(const bool x)
Definition: itkMath.h:824
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