ITK  4.3.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< class TInputImage, class TKernelImage = TInputImage, class TOutputImage = TInputImage, class TInternalPrecision=double >
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();
133 
134  virtual void PrintSelf( std::ostream & os, Indent indent ) const;
135 
136 private:
137  WienerDeconvolutionImageFilter(const Self &); //purposely not implemented
138  void operator=(const Self &); //purposely not implemented
139 
141 };
142 
143 namespace Functor
144 {
145 template< class TPixel >
147 {
148 public:
151 
153  {
154  return false;
155  }
156  bool operator==( const WienerDeconvolutionFunctor & other) const
157  {
158  return !(*this != other);
159  }
160  inline TPixel operator()(const TPixel & I, const TPixel & H) const
161  {
163 
164  // We estimate the power spectral density of the output image to
165  // be the same as the power spectral density of the blurred input
166  // minus the power spectral density of the noise.
167  TPixel Pf = std::norm( I );
168 
169  TPixel denominator = std::norm( H ) + ( Pn / (Pf - Pn) );
170  TPixel value = NumericTraits< TPixel >::ZeroValue();
171  if ( std::abs( denominator ) >= m_KernelZeroMagnitudeThreshold )
172  {
173  value = I * ( std::conj( H ) / denominator );
174  }
175 
176  return value;
177  }
178 
182  {
184  }
186  {
188  }
190 
194  {
196  }
198  {
200  }
202 
203 private:
206 };
207 } //namespace Functor
208 
209 }
210 
211 #ifndef ITK_MANUAL_INSTANTIATION
212 #include "itkWienerDeconvolutionImageFilter.hxx"
213 #endif
214 
215 #endif
216