ITK  4.13.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:
80  typedef InverseDeconvolutionImageFilter< TInputImage,
81  TKernelImage,
82  TOutputImage,
83  TInternalPrecision > Superclass;
86 
88  itkNewMacro(Self);
89 
92 
94  itkStaticConstMacro(ImageDimension, unsigned int,
95  TInputImage::ImageDimension);
96 
97  typedef TInputImage InputImageType;
98  typedef TOutputImage OutputImageType;
99  typedef TKernelImage KernelImageType;
100  typedef typename Superclass::InputPixelType InputPixelType;
101  typedef typename Superclass::OutputPixelType OutputPixelType;
102  typedef typename Superclass::KernelPixelType KernelPixelType;
103  typedef typename Superclass::InputIndexType InputIndexType;
104  typedef typename Superclass::OutputIndexType OutputIndexType;
105  typedef typename Superclass::KernelIndexType KernelIndexType;
106  typedef typename Superclass::InputSizeType InputSizeType;
107  typedef typename Superclass::OutputSizeType OutputSizeType;
108  typedef typename Superclass::KernelSizeType KernelSizeType;
110  typedef typename Superclass::InputRegionType InputRegionType;
111  typedef typename Superclass::OutputRegionType OutputRegionType;
112  typedef typename Superclass::KernelRegionType KernelRegionType;
113 
115  typedef typename Superclass::InternalImageType InternalImageType;
116  typedef typename Superclass::InternalImagePointerType InternalImagePointerType;
117  typedef typename Superclass::InternalComplexType InternalComplexType;
118  typedef typename Superclass::InternalComplexImageType InternalComplexImageType;
119  typedef typename Superclass::InternalComplexImagePointerType InternalComplexImagePointerType;
120 
123  itkSetMacro(NoiseVariance, double);
124  itkGetConstMacro(NoiseVariance, double);
126 
127 protected:
130 
132  void GenerateData() ITK_OVERRIDE;
133 
134  virtual void PrintSelf( std::ostream & os, Indent indent ) const ITK_OVERRIDE;
135 
136 private:
137  ITK_DISALLOW_COPY_AND_ASSIGN(WienerDeconvolutionImageFilter);
138 
139  double m_NoiseVariance;
140 };
141 
142 namespace Functor
143 {
144 template< typename TPixel >
145 class ITK_TEMPLATE_EXPORT WienerDeconvolutionFunctor
146 {
147 public:
148  WienerDeconvolutionFunctor() { m_KernelZeroMagnitudeThreshold = 0.0; }
150 
152  {
153  return false;
154  }
155  bool operator==( const WienerDeconvolutionFunctor & other) const
156  {
157  return !(*this != other);
158  }
159  inline TPixel operator()(const TPixel & I, const TPixel & H) const
160  {
161  TPixel Pn = m_NoisePowerSpectralDensityConstant;
162 
163  // We estimate the power spectral density of the output image to
164  // be the same as the power spectral density of the blurred input
165  // minus the power spectral density of the noise.
166  TPixel Pf = std::norm( I );
167 
168  TPixel denominator = std::norm( H ) + ( Pn / (Pf - Pn) );
169  TPixel value = NumericTraits< TPixel >::ZeroValue();
170  if ( std::abs( denominator ) >= m_KernelZeroMagnitudeThreshold )
171  {
172  value = I * ( std::conj( H ) / denominator );
173  }
174 
175  return value;
176  }
177 
181  {
182  m_NoisePowerSpectralDensityConstant = constant;
183  }
185  {
186  return m_NoisePowerSpectralDensityConstant;
187  }
189 
193  {
194  m_KernelZeroMagnitudeThreshold = mu;
195  }
197  {
198  return m_KernelZeroMagnitudeThreshold;
199  }
201 
202 private:
205 };
206 } //namespace Functor
207 
208 }
209 
210 #ifndef ITK_MANUAL_INSTANTIATION
211 #include "itkWienerDeconvolutionImageFilter.hxx"
212 #endif
213 
214 #endif
TPixel operator()(const TPixel &I, const TPixel &H) const
Superclass::InternalComplexImageType InternalComplexImageType
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.
unsigned long SizeValueType
Definition: itkIntTypes.h:143
Superclass::InternalImagePointerType InternalImagePointerType
bool operator!=(const WienerDeconvolutionFunctor &) const
bool operator==(const WienerDeconvolutionFunctor &other) const
InverseDeconvolutionImageFilter< TInputImage, TKernelImage, TOutputImage, TInternalPrecision > Superclass
Control indentation during Print() invocation.
Definition: itkIndent.h:49
The direct linear inverse deconvolution filter.
bool abs(const bool x)
Definition: itkMath.h:806
Superclass::InternalComplexImagePointerType InternalComplexImagePointerType