ITK  5.4.0
Insight Toolkit
itkInverseDeconvolutionImageFilter.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 itkInverseDeconvolutionImageFilter_h
19 #define itkInverseDeconvolutionImageFilter_h
20 
22 #include "itkMath.h"
23 
24 namespace itk
25 {
55 template <typename TInputImage,
56  typename TKernelImage = TInputImage,
57  typename TOutputImage = TInputImage,
58  typename TInternalPrecision = double>
59 class ITK_TEMPLATE_EXPORT InverseDeconvolutionImageFilter
60  : public FFTConvolutionImageFilter<TInputImage, TKernelImage, TOutputImage, TInternalPrecision>
61 {
62 public:
63  ITK_DISALLOW_COPY_AND_MOVE(InverseDeconvolutionImageFilter);
70 
72  itkNewMacro(Self);
73 
75  itkOverrideGetNameOfClassMacro(InverseDeconvolutionImageFilter);
76 
78  static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
79 
80  using InputImageType = TInputImage;
81  using OutputImageType = TOutputImage;
82  using KernelImageType = TKernelImage;
83  using typename Superclass::InputPixelType;
84  using typename Superclass::OutputPixelType;
85  using typename Superclass::KernelPixelType;
86  using typename Superclass::InputIndexType;
87  using typename Superclass::OutputIndexType;
88  using typename Superclass::KernelIndexType;
89  using typename Superclass::InputSizeType;
90  using typename Superclass::OutputSizeType;
91  using typename Superclass::KernelSizeType;
92  using typename Superclass::SizeValueType;
93  using typename Superclass::InputRegionType;
94  using typename Superclass::OutputRegionType;
95  using typename Superclass::KernelRegionType;
96 
98  using typename Superclass::InternalImageType;
99  using typename Superclass::InternalImagePointerType;
100  using typename Superclass::InternalComplexType;
101  using typename Superclass::InternalComplexImageType;
102  using typename Superclass::InternalComplexImagePointerType;
103 
107  itkSetMacro(KernelZeroMagnitudeThreshold, double);
108  itkGetConstMacro(KernelZeroMagnitudeThreshold, double);
111 protected:
113  ~InverseDeconvolutionImageFilter() override = default;
114 
116  void
117  GenerateData() override;
118 
119  void
120  PrintSelf(std::ostream & os, Indent indent) const override;
121 
122 private:
123  double m_KernelZeroMagnitudeThreshold{};
124 };
125 
126 namespace Functor
127 {
128 template <typename TInput1, typename TInput2, typename TOutput>
129 class ITK_TEMPLATE_EXPORT InverseDeconvolutionFunctor
130 {
131 public:
132  InverseDeconvolutionFunctor() { m_KernelZeroMagnitudeThreshold = 0.0; }
133  ~InverseDeconvolutionFunctor() = default;
134 
135  bool
137  {
138  return true;
139  }
140 
141  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(InverseDeconvolutionFunctor);
142 
143  inline TOutput
144  operator()(const TInput1 & I, const TInput2 & H) const
145  {
146  const double absH = itk::Math::abs(H);
147  TOutput value{};
148  if (absH >= m_KernelZeroMagnitudeThreshold)
149  {
150  value = static_cast<TOutput>(I / H);
151  }
152  return value;
153  }
154 
157  void
159  {
160  m_KernelZeroMagnitudeThreshold = mu;
161  }
162  double
164  {
165  return m_KernelZeroMagnitudeThreshold;
166  }
169 private:
171 };
172 } // namespace Functor
173 
174 } // namespace itk
175 
176 #ifndef ITK_MANUAL_INSTANTIATION
177 # include "itkInverseDeconvolutionImageFilter.hxx"
178 #endif
179 
180 #endif
itk::Functor::InverseDeconvolutionFunctor::InverseDeconvolutionFunctor
InverseDeconvolutionFunctor()
Definition: itkInverseDeconvolutionImageFilter.h:132
itk::FFTConvolutionImageFilter
Convolve a given image with an arbitrary image kernel using multiplication in the Fourier domain.
Definition: itkFFTConvolutionImageFilter.h:60
itk::Functor::InverseDeconvolutionFunctor::operator()
TOutput operator()(const TInput1 &I, const TInput2 &H) const
Definition: itkInverseDeconvolutionImageFilter.h:144
itk::ConvolutionImageFilterBase::KernelImageType
TKernelImage KernelImageType
Definition: itkConvolutionImageFilterBase.h:76
itk::Functor::InverseDeconvolutionFunctor::GetKernelZeroMagnitudeThreshold
double GetKernelZeroMagnitudeThreshold() const
Definition: itkInverseDeconvolutionImageFilter.h:163
itkFFTConvolutionImageFilter.h
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::Math::abs
bool abs(bool x)
Definition: itkMath.h:843
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::Functor::InverseDeconvolutionFunctor::m_KernelZeroMagnitudeThreshold
double m_KernelZeroMagnitudeThreshold
Definition: itkInverseDeconvolutionImageFilter.h:170
itk::InverseDeconvolutionImageFilter
The direct linear inverse deconvolution filter.
Definition: itkInverseDeconvolutionImageFilter.h:59
itk::ImageToImageFilter::InputImageType
TInputImage InputImageType
Definition: itkImageToImageFilter.h:129
itk::Functor::InverseDeconvolutionFunctor::operator==
bool operator==(const InverseDeconvolutionFunctor &) const
Definition: itkInverseDeconvolutionImageFilter.h:136
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:139
itk::Functor::InverseDeconvolutionFunctor
Definition: itkInverseDeconvolutionImageFilter.h:129
itk::Functor::InverseDeconvolutionFunctor::SetKernelZeroMagnitudeThreshold
void SetKernelZeroMagnitudeThreshold(double mu)
Definition: itkInverseDeconvolutionImageFilter.h:158
itkMath.h
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90