ITK  4.6.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
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  void PrintSelf(std::ostream & os, Indent indent) const
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 &); //purposely not implemented
117  void operator=(const Self &); //purposely not implemented
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
static const double pi
Definition: itkMath.h:55
TRealValueType Evaluate(const TRealValueType &u) const
virtual TRealValueType GetSigma() const
Kernel used for density estimation and nonparameteric regression.
void PrintSelf(std::ostream &os, Indent indent) const
void operator=(const Self &)
KernelFunctionBase< TRealValueType > Superclass
virtual TRealValueType GetFrequency() const
void PrintSelf(std::ostream &os, Indent indent) const
virtual bool GetCalculateImaginaryPart() const
virtual TRealValueType GetPhaseOffset() const
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Define additional traits for native types such as int or float.