ITK  6.0.0
Insight Toolkit
itkTikhonovDeconvolutionImageFilter.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 itkTikhonovDeconvolutionImageFilter_h
19 #define itkTikhonovDeconvolutionImageFilter_h
20 
22 
23 namespace itk
24 {
50 template <typename TInputImage,
51  typename TKernelImage = TInputImage,
52  typename TOutputImage = TInputImage,
53  typename TInternalPrecision = double>
54 class ITK_TEMPLATE_EXPORT TikhonovDeconvolutionImageFilter
55  : public InverseDeconvolutionImageFilter<TInputImage, TKernelImage, TOutputImage, TInternalPrecision>
56 {
57 public:
58  ITK_DISALLOW_COPY_AND_MOVE(TikhonovDeconvolutionImageFilter);
65 
67  itkNewMacro(Self);
68 
70  itkOverrideGetNameOfClassMacro(TikhonovDeconvolutionImageFilter);
71 
73  static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
74 
75  using InputImageType = TInputImage;
76  using OutputImageType = TOutputImage;
77  using KernelImageType = TKernelImage;
78  using typename Superclass::InputPixelType;
79  using typename Superclass::OutputPixelType;
80  using typename Superclass::KernelPixelType;
81  using typename Superclass::InputIndexType;
82  using typename Superclass::OutputIndexType;
83  using typename Superclass::KernelIndexType;
84  using typename Superclass::InputSizeType;
85  using typename Superclass::OutputSizeType;
86  using typename Superclass::KernelSizeType;
87  using typename Superclass::SizeValueType;
88  using typename Superclass::InputRegionType;
89  using typename Superclass::OutputRegionType;
90  using typename Superclass::KernelRegionType;
91 
93  using typename Superclass::InternalImageType;
94  using typename Superclass::InternalImagePointerType;
95  using typename Superclass::InternalComplexType;
96  using typename Superclass::InternalComplexImageType;
97  using typename Superclass::InternalComplexImagePointerType;
98 
103  itkSetMacro(RegularizationConstant, double);
104  itkGetConstMacro(RegularizationConstant, double);
107 protected:
109  ~TikhonovDeconvolutionImageFilter() override = default;
110 
112  void
113  GenerateData() override;
114 
115  void
116  PrintSelf(std::ostream & os, Indent indent) const override;
117 
118 private:
119  double m_RegularizationConstant{};
120 };
121 
122 namespace Functor
123 {
124 template <typename TInput1, typename TInput2, typename TOutput>
125 class ITK_TEMPLATE_EXPORT TikhonovDeconvolutionFunctor
126 {
127 public:
128  TikhonovDeconvolutionFunctor() = default;
129  ~TikhonovDeconvolutionFunctor() = default;
131  : m_RegularizationConstant(f.m_RegularizationConstant)
132  , m_KernelZeroMagnitudeThreshold(f.m_KernelZeroMagnitudeThreshold)
133  {}
134 
135  bool
137  {
138  return true;
139  }
140 
141  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(TikhonovDeconvolutionFunctor);
142 
143  inline TOutput
144  operator()(const TInput1 & I, const TInput2 & H) const
145  {
146  const typename TOutput::value_type normH = std::norm(H);
147  const typename TOutput::value_type denominator = normH + m_RegularizationConstant;
148  TOutput value{};
149  if (denominator >= m_KernelZeroMagnitudeThreshold)
150  {
151  value = static_cast<TOutput>(I * (std::conj(H) / denominator));
152  }
153 
154  return value;
155  }
156 
159  void
160  SetRegularizationConstant(double constant)
161  {
162  m_RegularizationConstant = constant;
163  }
164  double
166  {
167  return m_RegularizationConstant;
168  }
173  void
175  {
176  m_KernelZeroMagnitudeThreshold = mu;
177  }
178  double
180  {
181  return m_KernelZeroMagnitudeThreshold;
182  }
185 private:
186  double m_RegularizationConstant = 0.0;
187  double m_KernelZeroMagnitudeThreshold = 0.0;
188 };
189 } // namespace Functor
190 
191 } // namespace itk
192 
193 #ifndef ITK_MANUAL_INSTANTIATION
194 # include "itkTikhonovDeconvolutionImageFilter.hxx"
195 #endif
196 
197 #endif
itkInverseDeconvolutionImageFilter.h
itk::ConvolutionImageFilterBase::KernelImageType
TKernelImage KernelImageType
Definition: itkConvolutionImageFilterBase.h:75
itk::TikhonovDeconvolutionImageFilter
An inverse deconvolution filter regularized in the Tikhonov sense.
Definition: itkTikhonovDeconvolutionImageFilter.h:54
itk::Functor::TikhonovDeconvolutionFunctor::SetKernelZeroMagnitudeThreshold
void SetKernelZeroMagnitudeThreshold(double mu)
Definition: itkTikhonovDeconvolutionImageFilter.h:174
itk::Functor::TikhonovDeconvolutionFunctor::TikhonovDeconvolutionFunctor
TikhonovDeconvolutionFunctor(const TikhonovDeconvolutionFunctor &f)
Definition: itkTikhonovDeconvolutionImageFilter.h:130
itk::Functor::TikhonovDeconvolutionFunctor::operator()
TOutput operator()(const TInput1 &I, const TInput2 &H) const
Definition: itkTikhonovDeconvolutionImageFilter.h:144
itk::SmartPointer< Self >
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::InverseDeconvolutionImageFilter
The direct linear inverse deconvolution filter.
Definition: itkInverseDeconvolutionImageFilter.h:59
itk::Functor::TikhonovDeconvolutionFunctor::GetKernelZeroMagnitudeThreshold
double GetKernelZeroMagnitudeThreshold() const
Definition: itkTikhonovDeconvolutionImageFilter.h:179
itk::Functor::TikhonovDeconvolutionFunctor
Definition: itkTikhonovDeconvolutionImageFilter.h:125
itk::ImageToImageFilter::InputImageType
TInputImage InputImageType
Definition: itkImageToImageFilter.h:129
itk::Functor::TikhonovDeconvolutionFunctor::operator==
bool operator==(const TikhonovDeconvolutionFunctor &) const
Definition: itkTikhonovDeconvolutionImageFilter.h:136
itk::Functor::TikhonovDeconvolutionFunctor::GetRegularizationConstant
double GetRegularizationConstant() const
Definition: itkTikhonovDeconvolutionImageFilter.h:165
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:139
itk::Functor::TikhonovDeconvolutionFunctor::SetRegularizationConstant
void SetRegularizationConstant(double constant)
Definition: itkTikhonovDeconvolutionImageFilter.h:160
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:86
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90