ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkWienerDeconvolutionImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 itkWienerDeconvolutionImageFilter_h
19 #define itkWienerDeconvolutionImageFilter_h
20 
22 
23 namespace itk
24 {
74 template< typename TInputImage, typename TKernelImage = TInputImage, typename TOutputImage = TInputImage, typename TInternalPrecision=double >
75 class ITK_TEMPLATE_EXPORT WienerDeconvolutionImageFilter :
76  public InverseDeconvolutionImageFilter< TInputImage, TKernelImage, TOutputImage, TInternalPrecision >
77 {
78 public:
79  ITK_DISALLOW_COPY_AND_ASSIGN(WienerDeconvolutionImageFilter);
80 
82  using Superclass = InverseDeconvolutionImageFilter< TInputImage,
83  TKernelImage,
84  TOutputImage,
85  TInternalPrecision >;
88 
90  itkNewMacro(Self);
91 
94 
96  static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
97 
98  using InputImageType = TInputImage;
99  using OutputImageType = TOutputImage;
100  using KernelImageType = TKernelImage;
101  using InputPixelType = typename Superclass::InputPixelType;
102  using OutputPixelType = typename Superclass::OutputPixelType;
103  using KernelPixelType = typename Superclass::KernelPixelType;
104  using InputIndexType = typename Superclass::InputIndexType;
105  using OutputIndexType = typename Superclass::OutputIndexType;
106  using KernelIndexType = typename Superclass::KernelIndexType;
107  using InputSizeType = typename Superclass::InputSizeType;
108  using OutputSizeType = typename Superclass::OutputSizeType;
109  using KernelSizeType = typename Superclass::KernelSizeType;
111  using InputRegionType = typename Superclass::InputRegionType;
112  using OutputRegionType = typename Superclass::OutputRegionType;
113  using KernelRegionType = typename Superclass::KernelRegionType;
114 
116  using InternalImageType = typename Superclass::InternalImageType;
117  using InternalImagePointerType = typename Superclass::InternalImagePointerType;
118  using InternalComplexType = typename Superclass::InternalComplexType;
119  using InternalComplexImageType = typename Superclass::InternalComplexImageType;
120  using InternalComplexImagePointerType = typename Superclass::InternalComplexImagePointerType;
121 
124  itkSetMacro(NoiseVariance, double);
125  itkGetConstMacro(NoiseVariance, double);
127 
128 protected:
130  ~WienerDeconvolutionImageFilter() override = default;
131 
133  void GenerateData() override;
134 
135  void PrintSelf( std::ostream & os, Indent indent ) const override;
136 
137 private:
139 };
140 
141 namespace Functor
142 {
143 template< typename TPixel >
144 class ITK_TEMPLATE_EXPORT WienerDeconvolutionFunctor
145 {
146 public:
147  WienerDeconvolutionFunctor() { m_KernelZeroMagnitudeThreshold = 0.0; }
148  ~WienerDeconvolutionFunctor() = default;
149 
151  {
152  return false;
153  }
154  bool operator==( const WienerDeconvolutionFunctor & other) const
155  {
156  return !(*this != other);
157  }
158  inline TPixel operator()(const TPixel & I, const TPixel & H) const
159  {
160  TPixel Pn = m_NoisePowerSpectralDensityConstant;
161 
162  // We estimate the power spectral density of the output image to
163  // be the same as the power spectral density of the blurred input
164  // minus the power spectral density of the noise.
165  TPixel Pf = std::norm( I );
166 
167  TPixel denominator = std::norm( H ) + ( Pn / (Pf - Pn) );
168  TPixel value = NumericTraits< TPixel >::ZeroValue();
169  if ( std::abs( denominator ) >= m_KernelZeroMagnitudeThreshold )
170  {
171  value = I * ( std::conj( H ) / denominator );
172  }
173 
174  return value;
175  }
176 
180  {
181  m_NoisePowerSpectralDensityConstant = constant;
182  }
184  {
185  return m_NoisePowerSpectralDensityConstant;
186  }
188 
192  {
193  m_KernelZeroMagnitudeThreshold = mu;
194  }
196  {
197  return m_KernelZeroMagnitudeThreshold;
198  }
200 
201 private:
204 };
205 } //namespace Functor
206 
207 }
208 
209 #ifndef ITK_MANUAL_INSTANTIATION
210 #include "itkWienerDeconvolutionImageFilter.hxx"
211 #endif
212 
213 #endif
TPixel operator()(const TPixel &I, const TPixel &H) const
typename InternalImageType::Pointer InternalImagePointerType
typename InputImageType::PixelType InputPixelType
typename KernelImageType::SizeType KernelSizeType
typename OutputImageType::IndexType OutputIndexType
Define numeric traits for std::vector.
typename InputSizeType::SizeValueType SizeValueType
typename OutputImageType::PixelType OutputPixelType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
typename KernelImageType::PixelType KernelPixelType
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
The Wiener deconvolution image filter is designed to restore an image convolved with a blurring kerne...
Base class for all process objects that output image data.
typename InputImageType::RegionType InputRegionType
typename InternalComplexImageType::Pointer InternalComplexImagePointerType
bool operator!=(const WienerDeconvolutionFunctor &) const
std::complex< TInternalPrecision > InternalComplexType
TOutputImage OutputImageType
bool operator==(const WienerDeconvolutionFunctor &other) const
typename InputImageType::SizeType InputSizeType
typename InputImageType::IndexType InputIndexType
typename KernelImageType::RegionType KernelRegionType
typename OutputImageType::RegionType OutputRegionType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename OutputImageType::SizeType OutputSizeType
typename KernelImageType::IndexType KernelIndexType
The direct linear inverse deconvolution filter.
Templated n-dimensional image class.
Definition: itkImage.h:75