ITK  5.4.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  * https://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 ITK_TEMPLATE_EXPORT GaborKernelFunction : public KernelFunctionBase<TRealValueType>
52 {
53 public:
54  ITK_DISALLOW_COPY_AND_MOVE(GaborKernelFunction);
55 
60 
62  itkNewMacro(Self);
63 
65  itkOverrideGetNameOfClassMacro(GaborKernelFunction);
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(TRealValueType{ -0.5 } * parameter);
73  TRealValueType phase = TRealValueType{ 2.0 * itk::Math::pi } * this->m_Frequency * u + this->m_PhaseOffset;
76  if (this->m_CalculateImaginaryPart)
77  {
78  return envelope * std::sin(phase);
79  }
80  else
81  {
82  return envelope * std::cos(phase);
83  }
84  }
85 
87  itkSetMacro(Sigma, TRealValueType);
88  itkGetConstMacro(Sigma, TRealValueType);
92  itkSetMacro(Frequency, TRealValueType);
93  itkGetConstMacro(Frequency, TRealValueType);
97  itkSetMacro(PhaseOffset, TRealValueType);
98  itkGetConstMacro(PhaseOffset, TRealValueType);
103  itkSetMacro(CalculateImaginaryPart, bool);
104  itkGetConstMacro(CalculateImaginaryPart, bool);
105  itkBooleanMacro(CalculateImaginaryPart);
108 protected:
110  {
111  this->m_CalculateImaginaryPart = false;
112  this->m_Sigma = TRealValueType{ 1.0 };
113  this->m_Frequency = TRealValueType{ 0.4 };
114  this->m_PhaseOffset = TRealValueType{ 0.0 };
115  }
116  ~GaborKernelFunction() override = default;
117  void
118  PrintSelf(std::ostream & os, Indent indent) const override
119  {
120  Superclass::PrintSelf(os, indent);
121 
122  os << indent << "Sigma: " << this->GetSigma() << std::endl;
123  os << indent << "Frequency: " << this->GetFrequency() << std::endl;
124  os << indent << "PhaseOffset: " << this->GetPhaseOffset() << std::endl;
125  os << indent << "CalculateImaginaryPart: " << this->GetCalculateImaginaryPart() << std::endl;
126  }
127 
128 private:
129  TRealValueType m_Sigma{};
130 
131  TRealValueType m_Frequency{};
132 
133  TRealValueType m_PhaseOffset{};
134 
135  bool m_CalculateImaginaryPart{};
136 };
137 } // end namespace itk
138 
139 #endif
itk::KernelFunctionBase
Kernel used for density estimation and nonparametric regression.
Definition: itkKernelFunctionBase.h:43
itkKernelFunctionBase.h
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::GaborKernelFunction::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkGaborKernelFunction.h:118
itk::GaborKernelFunction::Evaluate
TRealValueType Evaluate(const TRealValueType &u) const override
Definition: itkGaborKernelFunction.h:69
itk::GaborKernelFunction
Gabor kernel used for various computer vision tasks.
Definition: itkGaborKernelFunction.h:51
itk::FunctionBase< TRealValueType, TRealValueType >
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::Math::pi
static constexpr double pi
Definition: itkMath.h:66
itk::GaborKernelFunction::GaborKernelFunction
GaborKernelFunction()
Definition: itkGaborKernelFunction.h:109