ITK  5.1.0
Insight Toolkit
itkGaussianDerivativeOperator.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 itkGaussianDerivativeOperator_h
19 #define itkGaussianDerivativeOperator_h
20 
21 #include "itkGaussianOperator.h"
22 #include "itkDerivativeOperator.h"
23 
24 #include <algorithm>
25 
26 namespace itk
27 {
77 template <typename TPixel, unsigned int VDimension = 2, typename TAllocator = NeighborhoodAllocator<TPixel>>
78 class ITK_TEMPLATE_EXPORT GaussianDerivativeOperator : public NeighborhoodOperator<TPixel, VDimension, TAllocator>
79 {
80 public:
81 
85 
89 
91  GaussianDerivativeOperator() = default;
92 
94  GaussianDerivativeOperator(const Self & other);
95 
97  Self &
98  operator=(const Self & other);
99 
100 
109  void
111  {
112  m_NormalizeAcrossScale = flag;
113  }
114  bool
116  {
117  return m_NormalizeAcrossScale;
118  }
119  itkBooleanMacro(NormalizeAcrossScale);
121 
125  void
126  SetVariance(const double variance)
127  {
128  m_Variance = variance;
129  }
130  double
131  GetVariance() const
132  {
133  return m_Variance;
134  }
136 
138  void
139  SetSpacing(const double spacing)
140  {
141  m_Spacing = spacing;
142  }
143  double
144  GetSpacing() const
145  {
146  return m_Spacing;
147  }
149 
154  void
155  SetMaximumError(const double maxerror)
156  {
157  constexpr double Min = 0.00001;
158  const double Max = 1.0 - Min;
159 
160  m_MaximumError = std::max(Min, std::min(Max, maxerror));
161  }
162  double
164  {
165  return m_MaximumError;
166  }
167 
172  void
173  SetMaximumKernelWidth(unsigned int n)
174  {
175  m_MaximumKernelWidth = n;
176  }
177 
179  void
180  SetOrder(const unsigned int order)
181  {
182  m_Order = order;
183  }
184  unsigned int
185  GetOrder() const
186  {
187  return m_Order;
188  }
190 
192  void
193  PrintSelf(std::ostream & os, Indent i) const override;
194 
195 protected:
197 
200  static double
201  ModifiedBesselI0(double);
202 
205  static double
206  ModifiedBesselI1(double);
207 
210  static double
211  ModifiedBesselI(int, double);
212 
215  GenerateCoefficients() override;
216 
218  void
219  Fill(const CoefficientVector & coeff) override
220  {
221  this->FillCenteredDirectional(coeff);
222  }
223 
224 private:
225  /* methods for generations of the coefficients for a gaussian
226  * operator of 0-order respecting the remaining parameters */
227  CoefficientVector
228  GenerateGaussianCoefficients() const;
229 
231  const char *
232  GetNameOfClass() const override
233  {
234  return "itkGaussianDerivativeOperator";
235  }
236 
238  bool m_NormalizeAcrossScale{ true };
239 
241  double m_Variance{ 1.0 };
242 
245  double m_MaximumError{ 0.005 };
246 
250  unsigned int m_MaximumKernelWidth{ 30 };
251 
253  unsigned int m_Order{ 1 };
254 
256  double m_Spacing{ 1.0 };
257 };
258 } // namespace itk
259 
260 #ifndef ITK_MANUAL_INSTANTIATION
261 # include "itkGaussianDerivativeOperator.hxx"
262 #endif
263 
264 #endif
itk::GaussianDerivativeOperator::SetOrder
void SetOrder(const unsigned int order)
Definition: itkGaussianDerivativeOperator.h:180
itk::GaussianDerivativeOperator::SetMaximumKernelWidth
void SetMaximumKernelWidth(unsigned int n)
Definition: itkGaussianDerivativeOperator.h:173
itk::NeighborhoodOperator
Virtual class that defines a common interface to all neighborhood operator subtypes.
Definition: itkNeighborhoodOperator.h:69
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::GaussianDerivativeOperator::GetNormalizeAcrossScale
bool GetNormalizeAcrossScale() const
Definition: itkGaussianDerivativeOperator.h:115
itk::GaussianDerivativeOperator::CoefficientVector
typename Superclass::CoefficientVector CoefficientVector
Definition: itkGaussianDerivativeOperator.h:196
itk::GaussianDerivativeOperator::GetNameOfClass
const char * GetNameOfClass() const override
Definition: itkGaussianDerivativeOperator.h:232
itk::GaussianDerivativeOperator::SetVariance
void SetVariance(const double variance)
Definition: itkGaussianDerivativeOperator.h:126
itk::GaussianDerivativeOperator::SetMaximumError
void SetMaximumError(const double maxerror)
Definition: itkGaussianDerivativeOperator.h:155
itk::GaussianOperator
A NeighborhoodOperator whose coefficients are a one dimensional, discrete Gaussian kernel.
Definition: itkGaussianOperator.h:66
itk::GaussianDerivativeOperator::SetNormalizeAcrossScale
void SetNormalizeAcrossScale(bool flag)
Definition: itkGaussianDerivativeOperator.h:110
itk::GaussianDerivativeOperator::GetOrder
unsigned int GetOrder() const
Definition: itkGaussianDerivativeOperator.h:185
itk::GaussianDerivativeOperator::GetSpacing
double GetSpacing() const
Definition: itkGaussianDerivativeOperator.h:144
itk::GaussianDerivativeOperator::Fill
void Fill(const CoefficientVector &coeff) override
Definition: itkGaussianDerivativeOperator.h:219
itk::GaussianDerivativeOperator::GetVariance
double GetVariance() const
Definition: itkGaussianDerivativeOperator.h:131
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkArray.h:26
itk::DerivativeOperator
A NeighborhoodOperator for taking an n-th order derivative at a pixel.
Definition: itkDerivativeOperator.h:66
itk::GaussianDerivativeOperator::SetSpacing
void SetSpacing(const double spacing)
Definition: itkGaussianDerivativeOperator.h:139
itkDerivativeOperator.h
itkGaussianOperator.h
itk::GaussianDerivativeOperator::GetMaximumError
double GetMaximumError()
Definition: itkGaussianDerivativeOperator.h:163
itk::GaussianDerivativeOperator
A NeighborhoodOperator whose coefficients are a one dimensional, discrete derivative Gaussian kernel.
Definition: itkGaussianDerivativeOperator.h:78
itk::NeighborhoodOperator::CoefficientVector
std::vector< PixelRealType > CoefficientVector
Definition: itkNeighborhoodOperator.h:165