ITK  6.0.0
Insight Toolkit
itkGaussianDerivativeOperator.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 itkGaussianDerivativeOperator_h
19 #define itkGaussianDerivativeOperator_h
20 
21 #include "itkGaussianOperator.h"
22 #include "itkDerivativeOperator.h"
23 
24 #include <algorithm>
25 
26 namespace itk
27 {
28 
35 {
36 public:
37 
42  enum class InterpolationMode : uint8_t
43  {
46  };
47 };
48 // Define how to print enumeration
49 extern ITKCommon_EXPORT std::ostream &
51 
104 template <typename TPixel, unsigned int VDimension = 2, typename TAllocator = NeighborhoodAllocator<TPixel>>
105 class ITK_TEMPLATE_EXPORT GaussianDerivativeOperator : public NeighborhoodOperator<TPixel, VDimension, TAllocator>
106 {
107 public:
108 
112 
114  itkOverrideGetNameOfClassMacro(GaussianDerivativeOperator);
115 
117 
121 
130  void
132  {
133  m_NormalizeAcrossScale = flag;
134  }
135  bool
137  {
138  return m_NormalizeAcrossScale;
139  }
140  itkBooleanMacro(NormalizeAcrossScale);
146  void
147  SetVariance(const double variance)
148  {
149  m_Variance = variance;
150  }
151  double
152  GetVariance() const
153  {
154  return m_Variance;
155  }
159  void
160  SetSpacing(const double spacing)
161  {
162  m_Spacing = spacing;
163  }
164  double
165  GetSpacing() const
166  {
167  return m_Spacing;
168  }
175  void
176  SetMaximumError(const double maxerror)
177  {
178  constexpr double Min = 0.00001;
179  const double Max = 1.0 - Min;
180 
181  m_MaximumError = std::clamp(maxerror, Min, Max);
182  }
183  double
185  {
186  return m_MaximumError;
187  }
188 
193  void
194  SetMaximumKernelWidth(unsigned int n)
195  {
196  m_MaximumKernelWidth = n;
197  }
198  itkGetConstMacro(MaximumKernelWidth, unsigned int);
202  void
203  SetOrder(const unsigned int order)
204  {
205  m_Order = order;
206  }
207  unsigned int
208  GetOrder() const
209  {
210  return m_Order;
211  }
214  void
215  PrintSelf(std::ostream & os, Indent indent) const override;
216 
217 protected:
219  using typename Superclass::CoefficientVector;
220 
223  static double
224  ModifiedBesselI0(double);
225 
228  static double
229  ModifiedBesselI1(double);
230 
233  static double
234  ModifiedBesselI(int, double);
235 
237  CoefficientVector
238  GenerateCoefficients() override;
239 
241  void
242  Fill(const CoefficientVector & coeff) override
243  {
244  this->FillCenteredDirectional(coeff);
245  }
246 
247 private:
248  /* Methods for generations of the coefficients for a Gaussian
249  * operator of 0-order respecting the remaining parameters. */
250  CoefficientVector
251  GenerateGaussianCoefficients() const;
252 
254  bool m_NormalizeAcrossScale{ true };
255 
257  double m_Variance{ 1.0 };
258 
261  double m_MaximumError{ 0.005 };
262 
266  unsigned int m_MaximumKernelWidth{ 30 };
267 
269  unsigned int m_Order{ 1 };
270 
272  double m_Spacing{ 1.0 };
273 };
274 
275 } // namespace itk
276 
277 #ifndef ITK_MANUAL_INSTANTIATION
278 # include "itkGaussianDerivativeOperator.hxx"
279 #endif
280 
281 #endif
itk::GaussianDerivativeOperator::SetOrder
void SetOrder(const unsigned int order)
Definition: itkGaussianDerivativeOperator.h:203
itk::GaussianDerivativeOperator::SetMaximumKernelWidth
void SetMaximumKernelWidth(unsigned int n)
Definition: itkGaussianDerivativeOperator.h:194
itk::operator<<
std::ostream & operator<<(std::ostream &os, const Array< TValue > &arr)
Definition: itkArray.h:216
itk::NeighborhoodOperator
Virtual class that defines a common interface to all neighborhood operator subtypes.
Definition: itkNeighborhoodOperator.h:72
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::NeighborhoodOperator::CoefficientVector
typename std::vector< PixelRealType > CoefficientVector
Definition: itkNeighborhoodOperator.h:153
itk::GaussianDerivativeOperatorEnums::InterpolationMode::NearestNeighbourInterpolation
itk::GaussianDerivativeOperator::GetNormalizeAcrossScale
bool GetNormalizeAcrossScale() const
Definition: itkGaussianDerivativeOperator.h:136
itk::GaussianDerivativeOperator::SetVariance
void SetVariance(const double variance)
Definition: itkGaussianDerivativeOperator.h:147
itk::GaussianDerivativeOperator::SetMaximumError
void SetMaximumError(const double maxerror)
Definition: itkGaussianDerivativeOperator.h:176
itk::GaussianOperator
A NeighborhoodOperator whose coefficients are a one dimensional, discrete Gaussian kernel.
Definition: itkGaussianOperator.h:69
itk::GaussianDerivativeOperator::SetNormalizeAcrossScale
void SetNormalizeAcrossScale(bool flag)
Definition: itkGaussianDerivativeOperator.h:131
itk::GaussianDerivativeOperatorEnums
GaussianDerivativeOperator class enum classes.
Definition: itkGaussianDerivativeOperator.h:34
itk::GaussianDerivativeOperator::GetOrder
unsigned int GetOrder() const
Definition: itkGaussianDerivativeOperator.h:208
itk::GaussianDerivativeOperator::GetSpacing
double GetSpacing() const
Definition: itkGaussianDerivativeOperator.h:165
itk::GaussianDerivativeOperator::Fill
void Fill(const CoefficientVector &coeff) override
Definition: itkGaussianDerivativeOperator.h:242
itk::GaussianDerivativeOperator::GetVariance
double GetVariance() const
Definition: itkGaussianDerivativeOperator.h:152
itk::GaussianDerivativeOperatorEnums::InterpolationMode
InterpolationMode
Definition: itkGaussianDerivativeOperator.h:42
itk::GaussianDerivativeOperatorEnums::InterpolationMode::LinearInterpolation
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::DerivativeOperator
A NeighborhoodOperator for taking an n-th order derivative at a pixel.
Definition: itkDerivativeOperator.h:69
itk::GaussianDerivativeOperator::SetSpacing
void SetSpacing(const double spacing)
Definition: itkGaussianDerivativeOperator.h:160
itkDerivativeOperator.h
itkGaussianOperator.h
itk::GaussianDerivativeOperator::GetMaximumError
double GetMaximumError()
Definition: itkGaussianDerivativeOperator.h:184
itk::GaussianDerivativeOperator
A NeighborhoodOperator whose coefficients are a one dimensional, discrete derivative Gaussian kernel.
Definition: itkGaussianDerivativeOperator.h:105