ITK  5.2.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  * 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 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);
105 
111 
112  using RealType = typename Superclass::RealType;
114 
116  itkNewMacro(Self);
117 
120 
125  itkGetConstMacro(Sigma, ScalarRealType);
126  itkSetMacro(Sigma, ScalarRealType);
128 
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 
191  itkSetMacro(Order, GaussianOrderEnum);
192  itkGetConstMacro(Order, GaussianOrderEnum);
194 
196  void
197  SetZeroOrder();
198 
200  void
201  SetFirstOrder();
202 
204  void
205  SetSecondOrder();
206 
207 protected:
209  ~RecursiveGaussianImageFilter() override = default;
210  void
211  PrintSelf(std::ostream & os, Indent indent) const override;
212 
217  void
218  SetUp(ScalarRealType spacing) override;
219 
220  /* See superclass for doxygen. This method adds the additional check
221  * that sigma is greater than zero. */
222  void
223  VerifyPreconditions() ITKv5_CONST override;
224 
225 private:
227  void
228  ComputeNCoefficients(ScalarRealType sigmad,
229  ScalarRealType A1,
230  ScalarRealType B1,
231  ScalarRealType W1,
232  ScalarRealType L1,
233  ScalarRealType A2,
234  ScalarRealType B2,
235  ScalarRealType W2,
236  ScalarRealType L2,
237  ScalarRealType & N0,
238  ScalarRealType & N1,
239  ScalarRealType & N2,
240  ScalarRealType & N3,
241  ScalarRealType & SN,
242  ScalarRealType & DN,
243  ScalarRealType & EN);
244 
246  void
247  ComputeDCoefficients(ScalarRealType sigmad,
248  ScalarRealType W1,
249  ScalarRealType L1,
250  ScalarRealType W2,
251  ScalarRealType L2,
252  ScalarRealType & SD,
253  ScalarRealType & DD,
254  ScalarRealType & ED);
255 
258  void
259  ComputeRemainingCoefficients(bool symmetric);
260 
262  ScalarRealType m_Sigma;
263 
265  bool m_NormalizeAcrossScale;
266 
268 };
269 } // end namespace itk
270 
271 #ifndef ITK_MANUAL_INSTANTIATION
272 # include "itkRecursiveGaussianImageFilter.hxx"
273 #endif
274 
275 #endif
itk::RecursiveSeparableImageFilter::ScalarRealType
typename NumericTraits< InputPixelType >::ScalarRealType ScalarRealType
Definition: itkRecursiveSeparableImageFilter.h:77
itk::uint8_t
::uint8_t uint8_t
Definition: itkIntTypes.h:29
GaussianOrder
itk::RecursiveGaussianImageFilterEnums::GaussianOrder::FirstOrder
itk::operator<<
std::ostream & operator<<(std::ostream &os, const Array< TValue > &arr)
Definition: itkArray.h:218
itk::RecursiveGaussianImageFilterEnums::GaussianOrder
GaussianOrder
Definition: itkRecursiveGaussianImageFilter.h:38
itk::GaussianOrderEnum
RecursiveGaussianImageFilterEnums::GaussianOrder GaussianOrderEnum
Definition: itkRecursiveGaussianImageFilter.h:49
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: itkAnnulusOperator.h:24
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:138
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::RecursiveSeparableImageFilter::RealType
typename NumericTraits< InputPixelType >::RealType RealType
Definition: itkRecursiveSeparableImageFilter.h:76
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90