ITK  6.0.0
Insight Toolkit
itkRecursiveGaussianImageFilter.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 itkRecursiveGaussianImageFilter_h
19 #define itkRecursiveGaussianImageFilter_h
20 
22 #include "ITKSmoothingExport.h"
23 
24 namespace itk
25 {
31 {
32 public:
38  enum class GaussianOrder : uint8_t
39  {
40  ZeroOrder = 0,
41  FirstOrder = 1,
42  SecondOrder = 2
43  };
44 };
45 // Define how to print enumeration
46 extern ITKSmoothing_EXPORT std::ostream &
47  operator<<(std::ostream & out, const RecursiveGaussianImageFilterEnums::GaussianOrder value);
48 
50 #if !defined(ITK_LEGACY_REMOVE)
51 
52 using OrderEnumType = GaussianOrderEnum;
53 using EnumGaussianOrderType = GaussianOrderEnum;
54 // We need to expose the enum values at the class level
55 // for backwards compatibility
56 static constexpr GaussianOrderEnum ZeroOrder = GaussianOrderEnum::ZeroOrder;
57 static constexpr GaussianOrderEnum FirstOrder = GaussianOrderEnum::FirstOrder;
58 static constexpr GaussianOrderEnum SecondOrder = GaussianOrderEnum::SecondOrder;
59 #endif
60 
99 template <typename TInputImage, typename TOutputImage = TInputImage>
100 class ITK_TEMPLATE_EXPORT RecursiveGaussianImageFilter : public RecursiveSeparableImageFilter<TInputImage, TOutputImage>
101 {
102 public:
103  ITK_DISALLOW_COPY_AND_MOVE(RecursiveGaussianImageFilter);
111 
112  using typename Superclass::RealType;
113  using typename Superclass::ScalarRealType;
114 
116  itkNewMacro(Self);
117 
119  itkOverrideGetNameOfClassMacro(RecursiveGaussianImageFilter);
120 
125  itkGetConstMacro(Sigma, ScalarRealType);
126  itkSetMacro(Sigma, ScalarRealType);
130  using OutputImageType = TOutputImage;
131 
132 #if !defined(ITK_LEGACY_REMOVE)
133 
134  using OrderEnumType = GaussianOrderEnum;
135  using EnumGaussianOrderType = GaussianOrderEnum;
136  // We need to expose the enum values at the class level
137  // for backwards compatibility
138  static constexpr GaussianOrderEnum ZeroOrder = GaussianOrderEnum::ZeroOrder;
139  static constexpr GaussianOrderEnum FirstOrder = GaussianOrderEnum::FirstOrder;
140  static constexpr GaussianOrderEnum SecondOrder = GaussianOrderEnum::SecondOrder;
141 #endif
142 
182  itkSetMacro(NormalizeAcrossScale, bool);
183  itkGetConstMacro(NormalizeAcrossScale, bool);
184  itkBooleanMacro(NormalizeAcrossScale);
185 
192  itkSetMacro(Order, GaussianOrderEnum);
193  itkGetConstMacro(Order, GaussianOrderEnum);
197  void
198  SetZeroOrder();
199 
201  void
202  SetFirstOrder();
203 
205  void
206  SetSecondOrder();
207 
208 protected:
210  ~RecursiveGaussianImageFilter() override = default;
211  void
212  PrintSelf(std::ostream & os, Indent indent) const override;
213 
218  void
219  SetUp(ScalarRealType spacing) override;
220 
221  /* See superclass for doxygen. This method adds the additional check
222  * that sigma is greater than zero. */
223  void
224  VerifyPreconditions() const override;
225 
226 private:
228  void
229  ComputeNCoefficients(ScalarRealType sigmad,
230  ScalarRealType A1,
231  ScalarRealType B1,
232  ScalarRealType W1,
233  ScalarRealType L1,
234  ScalarRealType A2,
235  ScalarRealType B2,
236  ScalarRealType W2,
237  ScalarRealType L2,
238  ScalarRealType & N0,
239  ScalarRealType & N1,
240  ScalarRealType & N2,
241  ScalarRealType & N3,
242  ScalarRealType & SN,
243  ScalarRealType & DN,
244  ScalarRealType & EN);
245 
247  void
248  ComputeDCoefficients(ScalarRealType sigmad,
249  ScalarRealType W1,
250  ScalarRealType L1,
251  ScalarRealType W2,
252  ScalarRealType L2,
253  ScalarRealType & SD,
254  ScalarRealType & DD,
255  ScalarRealType & ED);
256 
259  void
260  ComputeRemainingCoefficients(bool symmetric);
261 
263  ScalarRealType m_Sigma{};
264 
266  bool m_NormalizeAcrossScale{};
267 
268  GaussianOrderEnum m_Order{};
269 };
270 } // end namespace itk
271 
272 #ifndef ITK_MANUAL_INSTANTIATION
273 # include "itkRecursiveGaussianImageFilter.hxx"
274 #endif
275 
276 #endif
itk::RecursiveSeparableImageFilter::ScalarRealType
typename NumericTraits< InputPixelType >::ScalarRealType ScalarRealType
Definition: itkRecursiveSeparableImageFilter.h:77
GaussianOrder
itk::RecursiveGaussianImageFilterEnums::GaussianOrder::FirstOrder
itk::RecursiveGaussianImageFilterEnums::GaussianOrder
GaussianOrder
Definition: itkRecursiveGaussianImageFilter.h:38
itk::GaussianOrderEnum
RecursiveGaussianImageFilterEnums::GaussianOrder GaussianOrderEnum
Definition: itkRecursiveGaussianImageFilter.h:49
itk::operator<<
ITKCommon_EXPORT std::ostream & operator<<(std::ostream &out, typename AnatomicalOrientation::CoordinateEnum value)
itk::SmartPointer< Self >
itk::RecursiveSeparableImageFilter
Base class for recursive convolution with a kernel.
Definition: itkRecursiveSeparableImageFilter.h:52
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::RecursiveGaussianImageFilterEnums::GaussianOrder::SecondOrder
itkRecursiveSeparableImageFilter.h
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::RecursiveGaussianImageFilterEnums::GaussianOrder::ZeroOrder
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:139
itk::RecursiveGaussianImageFilter
Base class for computing IIR convolution with an approximation of a Gaussian kernel.
Definition: itkRecursiveGaussianImageFilter.h:100
itk::RecursiveGaussianImageFilterEnums
Contains all enum classes used by RecursiveGaussianImageFilter class.
Definition: itkRecursiveGaussianImageFilter.h:30
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90