ITK  6.0.0
Insight Toolkit
itkGaussianOperator.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 itkGaussianOperator_h
19 #define itkGaussianOperator_h
20 
22 #include <cmath>
23 namespace itk
24 {
68 template <typename TPixel, unsigned int VDimension = 2, typename TAllocator = NeighborhoodAllocator<TPixel>>
69 class ITK_TEMPLATE_EXPORT GaussianOperator : public NeighborhoodOperator<TPixel, VDimension, TAllocator>
70 {
71 public:
72 
76 
78  itkOverrideGetNameOfClassMacro(GaussianOperator);
79 
81  void
82  SetVariance(const double variance)
83  {
84  m_Variance = variance;
85  }
86 
91  void
92  SetMaximumError(const double max_error)
93  {
94  if (max_error >= 1 || max_error <= 0)
95  {
96  itkExceptionMacro("Maximum Error Must be in the range [ 0.0 , 1.0 ]");
97  }
98 
99  m_MaximumError = max_error;
100  }
101 
103  double
105  {
106  return m_Variance;
107  }
108 
113  double
115  {
116  return m_MaximumError;
117  }
118 
123  void
124  SetMaximumKernelWidth(unsigned int n)
125  {
126  m_MaximumKernelWidth = n;
127  }
128 
130  unsigned int
132  {
133  return m_MaximumKernelWidth;
134  }
135 
136  void
137  PrintSelf(std::ostream & os, Indent indent) const override
138  {
139  Superclass::PrintSelf(os, indent);
140 
141  os << indent << "Variance: " << m_Variance << std::endl;
142  os << indent << "MaximumError: " << m_MaximumError << std::endl;
143  os << indent << "MaximumKernelWidth: " << m_MaximumKernelWidth << std::endl;
144  }
145 
149  bool
150  GetDebug() const
151  {
152  return m_Debug;
153  }
154 
156  void
157  DebugOn() const
158  {
159  m_Debug = true;
160  }
161 
163  void
164  DebugOff() const
165  {
166  m_Debug = false;
167  }
168 
170  void
171  SetDebug(bool debugFlag) const
172  {
173  m_Debug = debugFlag;
174  }
175 
176 public:
179  double
180  ModifiedBesselI0(double);
181 
184  double
185  ModifiedBesselI1(double);
186 
189  double
190  ModifiedBesselI(int, double);
191 
192 protected:
194  using typename Superclass::CoefficientVector;
195 
197  CoefficientVector
198  GenerateCoefficients() override;
199 
201  void
202  Fill(const CoefficientVector & coeff) override
203  {
204  this->FillCenteredDirectional(coeff);
205  }
206 
207 private:
209  double m_Variance{ 1 };
210 
213  double m_MaximumError{ .01 };
214 
218  unsigned int m_MaximumKernelWidth{ 30 };
219 
221  mutable bool m_Debug{ false };
222 };
223 } // namespace itk
224 
225 #ifndef ITK_MANUAL_INSTANTIATION
226 # include "itkGaussianOperator.hxx"
227 #endif
228 
229 #endif
itk::GaussianOperator::GetDebug
bool GetDebug() const
Definition: itkGaussianOperator.h:150
itk::GaussianOperator::GetMaximumKernelWidth
unsigned int GetMaximumKernelWidth() const
Definition: itkGaussianOperator.h:131
itk::NeighborhoodOperator
Virtual class that defines a common interface to all neighborhood operator subtypes.
Definition: itkNeighborhoodOperator.h:72
itkNeighborhoodOperator.h
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::GaussianOperator::DebugOff
void DebugOff() const
Definition: itkGaussianOperator.h:164
itk::GaussianOperator::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkGaussianOperator.h:137
itk::GaussianOperator::GetVariance
double GetVariance()
Definition: itkGaussianOperator.h:104
itk::GaussianOperator::SetDebug
void SetDebug(bool debugFlag) const
Definition: itkGaussianOperator.h:171
itk::GaussianOperator
A NeighborhoodOperator whose coefficients are a one dimensional, discrete Gaussian kernel.
Definition: itkGaussianOperator.h:69
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::GaussianOperator::GetMaximumError
double GetMaximumError()
Definition: itkGaussianOperator.h:114
itk::GaussianOperator::Fill
void Fill(const CoefficientVector &coeff) override
Definition: itkGaussianOperator.h:202
itk::GaussianOperator::DebugOn
void DebugOn() const
Definition: itkGaussianOperator.h:157
itk::GaussianOperator::SetMaximumError
void SetMaximumError(const double max_error)
Definition: itkGaussianOperator.h:92
itk::GaussianOperator< ScalarType, Superclass::Dimension >::CoefficientVector
typename std::vector< PixelRealType > CoefficientVector
Definition: itkNeighborhoodOperator.h:153
itk::GaussianOperator::SetMaximumKernelWidth
void SetMaximumKernelWidth(unsigned int n)
Definition: itkGaussianOperator.h:124
itk::GaussianOperator::SetVariance
void SetVariance(const double variance)
Definition: itkGaussianOperator.h:82