ITK  5.0.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:
53  ITK_DISALLOW_COPY_AND_ASSIGN(GaborKernelFunction);
54 
59 
61  itkNewMacro(Self);
62 
65 
67  TRealValueType Evaluate(const TRealValueType & u) const override
68  {
69  TRealValueType parameter = itk::Math::sqr(u / this->m_Sigma);
70  TRealValueType envelope = std::exp(static_cast< TRealValueType >(-0.5) * parameter);
71  TRealValueType phase = static_cast< TRealValueType >(2.0 * itk::Math::pi) * this->m_Frequency * u
72  + this->m_PhaseOffset;
74 
75  if ( this->m_CalculateImaginaryPart )
76  {
77  return envelope * std::sin(phase);
78  }
79  else
80  {
81  return envelope * std::cos(phase);
82  }
83  }
84 
86  itkSetMacro(Sigma, TRealValueType);
87  itkGetConstMacro(Sigma, TRealValueType);
89 
91  itkSetMacro(Frequency, TRealValueType);
92  itkGetConstMacro(Frequency, TRealValueType);
94 
96  itkSetMacro(PhaseOffset, TRealValueType);
97  itkGetConstMacro(PhaseOffset, TRealValueType);
99 
102  itkSetMacro(CalculateImaginaryPart, bool);
103  itkGetConstMacro(CalculateImaginaryPart, bool);
104  itkBooleanMacro(CalculateImaginaryPart);
106 
107 protected:
109  {
110  this->m_CalculateImaginaryPart = false;
112  this->m_Frequency = static_cast<TRealValueType>(0.4);
114  }
115  ~GaborKernelFunction() override = default;
116  void PrintSelf(std::ostream & os, Indent indent) const override
117  {
118  Superclass::PrintSelf(os, indent);
119 
120  os << indent << "Sigma: " << this->GetSigma() << std::endl;
121  os << indent << "Frequency: " << this->GetFrequency() << std::endl;
122  os << indent << "PhaseOffset: " << this->GetPhaseOffset() << std::endl;
123  os << indent << "CalculateImaginaryPart: " << this->GetCalculateImaginaryPart() << std::endl;
124  }
125 
126 private:
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.
Define numeric traits for std::vector.
void PrintSelf(std::ostream &os, Indent indent) const override
static constexpr double pi
Definition: itkMath.h:63
virtual TRealValueType GetSigma() const
Kernel used for density estimation and nonparameteric regression.
virtual TRealValueType GetFrequency() const
TRealValueType Evaluate(const TRealValueType &u) const override
virtual bool GetCalculateImaginaryPart() const
~GaborKernelFunction() override=default
virtual TRealValueType GetPhaseOffset() const
Control indentation during Print() invocation.
Definition: itkIndent.h:49
void PrintSelf(std::ostream &os, Indent indent) const override