ITK  5.2.0
Insight Toolkit
itkGaborKernelFunction.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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 {
50 template <typename TRealValueType>
51 class GaborKernelFunction : public KernelFunctionBase<TRealValueType>
52 {
53 public:
54  ITK_DISALLOW_COPY_AND_ASSIGN(GaborKernelFunction);
55 
60 
62  itkNewMacro(Self);
63 
66 
68  TRealValueType
69  Evaluate(const TRealValueType & u) const override
70  {
71  TRealValueType parameter = itk::Math::sqr(u / this->m_Sigma);
72  TRealValueType envelope = std::exp(static_cast<TRealValueType>(-0.5) * parameter);
73  TRealValueType phase =
74  static_cast<TRealValueType>(2.0 * itk::Math::pi) * this->m_Frequency * u + this->m_PhaseOffset;
76 
77  if (this->m_CalculateImaginaryPart)
78  {
79  return envelope * std::sin(phase);
80  }
81  else
82  {
83  return envelope * std::cos(phase);
84  }
85  }
86 
88  itkSetMacro(Sigma, TRealValueType);
89  itkGetConstMacro(Sigma, TRealValueType);
91 
93  itkSetMacro(Frequency, TRealValueType);
94  itkGetConstMacro(Frequency, TRealValueType);
96 
98  itkSetMacro(PhaseOffset, TRealValueType);
99  itkGetConstMacro(PhaseOffset, TRealValueType);
101 
104  itkSetMacro(CalculateImaginaryPart, bool);
105  itkGetConstMacro(CalculateImaginaryPart, bool);
106  itkBooleanMacro(CalculateImaginaryPart);
108 
109 protected:
111  {
112  this->m_CalculateImaginaryPart = false;
114  this->m_Frequency = static_cast<TRealValueType>(0.4);
116  }
117  ~GaborKernelFunction() override = default;
118  void
119  PrintSelf(std::ostream & os, Indent indent) const override
120  {
121  Superclass::PrintSelf(os, indent);
122 
123  os << indent << "Sigma: " << this->GetSigma() << std::endl;
124  os << indent << "Frequency: " << this->GetFrequency() << std::endl;
125  os << indent << "PhaseOffset: " << this->GetPhaseOffset() << std::endl;
126  os << indent << "CalculateImaginaryPart: " << this->GetCalculateImaginaryPart() << std::endl;
127  }
128 
129 private:
130  TRealValueType m_Sigma;
131 
132  TRealValueType m_Frequency;
133 
134  TRealValueType m_PhaseOffset;
135 
137 };
138 } // end namespace itk
139 
140 #endif
itk::GaborKernelFunction::m_Frequency
TRealValueType m_Frequency
Definition: itkGaborKernelFunction.h:132
itk::GaborKernelFunction::m_Sigma
TRealValueType m_Sigma
Definition: itkGaborKernelFunction.h:130
itk::KernelFunctionBase
Kernel used for density estimation and nonparametric regression.
Definition: itkKernelFunctionBase.h:43
itkKernelFunctionBase.h
itk::SmartPointer< Self >
itk::GaborKernelFunction::~GaborKernelFunction
~GaborKernelFunction() override=default
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::GaborKernelFunction::GetSigma
virtual TRealValueType GetSigma() const
itk::GaborKernelFunction::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkGaborKernelFunction.h:119
itk::GaborKernelFunction::Evaluate
TRealValueType Evaluate(const TRealValueType &u) const override
Definition: itkGaborKernelFunction.h:69
itk::NumericTraits::OneValue
static T OneValue()
Definition: itkNumericTraits.h:156
itk::GaborKernelFunction::GetPhaseOffset
virtual TRealValueType GetPhaseOffset() const
itk::KernelFunctionBase::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkKernelFunctionBase.h:71
itk::GaborKernelFunction
Gabor kernel used for various computer vision tasks.
Definition: itkGaborKernelFunction.h:51
itk::FunctionBase< TRealValueType, TRealValueType >
itk::NumericTraits::ZeroValue
static T ZeroValue()
Definition: itkNumericTraits.h:148
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::GaborKernelFunction::m_PhaseOffset
TRealValueType m_PhaseOffset
Definition: itkGaborKernelFunction.h:134
itk::Math::pi
static constexpr double pi
Definition: itkMath.h:64
itk::GaborKernelFunction::m_CalculateImaginaryPart
bool m_CalculateImaginaryPart
Definition: itkGaborKernelFunction.h:136
itk::GaborKernelFunction::GetCalculateImaginaryPart
virtual bool GetCalculateImaginaryPart() const
itk::GaborKernelFunction::GetFrequency
virtual TRealValueType GetFrequency() const
itk::GaborKernelFunction::GaborKernelFunction
GaborKernelFunction()
Definition: itkGaborKernelFunction.h:110