![]() |
ITK
4.2.0
Insight Segmentation and Registration Toolkit
|
00001 /*========================================================================= 00002 * 00003 * Copyright Insight Software Consortium 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0.txt 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 * 00017 *=========================================================================*/ 00018 #ifndef __itkWienerDeconvolutionImageFilter_h 00019 #define __itkWienerDeconvolutionImageFilter_h 00020 00021 #include "itkInverseDeconvolutionImageFilter.h" 00022 00023 namespace itk 00024 { 00074 template< class TInputImage, class TKernelImage = TInputImage, class TOutputImage = TInputImage, class TInternalPrecision=double > 00075 class ITK_EXPORT WienerDeconvolutionImageFilter : 00076 public InverseDeconvolutionImageFilter< TInputImage, TKernelImage, TOutputImage, TInternalPrecision > 00077 { 00078 public: 00079 typedef WienerDeconvolutionImageFilter Self; 00080 typedef InverseDeconvolutionImageFilter< TInputImage, 00081 TKernelImage, 00082 TOutputImage, 00083 TInternalPrecision > Superclass; 00084 typedef SmartPointer< Self > Pointer; 00085 typedef SmartPointer< const Self > ConstPointer; 00086 00088 itkNewMacro(Self); 00089 00091 itkTypeMacro(WienerDeconvolutionImageFilter, InverseDeconvolutionImageFilter); 00092 00094 itkStaticConstMacro(ImageDimension, unsigned int, 00095 TInputImage::ImageDimension); 00096 00097 typedef TInputImage InputImageType; 00098 typedef TOutputImage OutputImageType; 00099 typedef TKernelImage KernelImageType; 00100 typedef typename Superclass::InputPixelType InputPixelType; 00101 typedef typename Superclass::OutputPixelType OutputPixelType; 00102 typedef typename Superclass::KernelPixelType KernelPixelType; 00103 typedef typename Superclass::InputIndexType InputIndexType; 00104 typedef typename Superclass::OutputIndexType OutputIndexType; 00105 typedef typename Superclass::KernelIndexType KernelIndexType; 00106 typedef typename Superclass::InputSizeType InputSizeType; 00107 typedef typename Superclass::OutputSizeType OutputSizeType; 00108 typedef typename Superclass::KernelSizeType KernelSizeType; 00109 typedef typename Superclass::SizeValueType SizeValueType; 00110 typedef typename Superclass::InputRegionType InputRegionType; 00111 typedef typename Superclass::OutputRegionType OutputRegionType; 00112 typedef typename Superclass::KernelRegionType KernelRegionType; 00113 00115 typedef typename Superclass::InternalImageType InternalImageType; 00116 typedef typename Superclass::InternalImagePointerType InternalImagePointerType; 00117 typedef typename Superclass::InternalComplexType InternalComplexType; 00118 typedef typename Superclass::InternalComplexImageType InternalComplexImageType; 00119 typedef typename Superclass::InternalComplexImagePointerType InternalComplexImagePointerType; 00120 00123 itkSetMacro(NoiseVariance, double); 00124 itkGetConstMacro(NoiseVariance, double); 00126 00127 protected: 00128 WienerDeconvolutionImageFilter(); 00129 ~WienerDeconvolutionImageFilter() {} 00130 00132 void GenerateData(); 00133 00134 virtual void PrintSelf( std::ostream & os, Indent indent ) const; 00135 00136 private: 00137 WienerDeconvolutionImageFilter(const Self &); //purposely not implemented 00138 void operator=(const Self &); //purposely not implemented 00139 00140 double m_NoiseVariance; 00141 }; 00142 00143 namespace Functor 00144 { 00145 template< class TPixel > 00146 class WienerDeconvolutionFunctor 00147 { 00148 public: 00149 WienerDeconvolutionFunctor() { m_KernelZeroMagnitudeThreshold = 0.0; } 00150 ~WienerDeconvolutionFunctor() {} 00151 00152 bool operator!=( const WienerDeconvolutionFunctor & ) const 00153 { 00154 return false; 00155 } 00156 bool operator==( const WienerDeconvolutionFunctor & other) const 00157 { 00158 return !(*this != other); 00159 } 00160 inline TPixel operator()(const TPixel & I, const TPixel & H) const 00161 { 00162 TPixel Pn = m_NoisePowerSpectralDensityConstant; 00163 00164 // We estimate the power spectral density of the output image to 00165 // be the same as the power spectral density of the blurred input 00166 // minus the power spectral density of the noise. 00167 TPixel Pf = std::norm( I ); 00168 00169 TPixel denominator = std::norm( H ) + ( Pn / (Pf - Pn) ); 00170 TPixel value = NumericTraits< TPixel >::ZeroValue(); 00171 if ( std::abs( denominator ) >= m_KernelZeroMagnitudeThreshold ) 00172 { 00173 value = I * ( std::conj( H ) / denominator ); 00174 } 00175 00176 return value; 00177 } 00178 00181 void SetNoisePowerSpectralDensityConstant(double constant) 00182 { 00183 m_NoisePowerSpectralDensityConstant = constant; 00184 } 00185 double GetNoisePowerSpectralDensityConstant() const 00186 { 00187 return m_NoisePowerSpectralDensityConstant; 00188 } 00190 00193 void SetKernelZeroMagnitudeThreshold(double mu) 00194 { 00195 m_KernelZeroMagnitudeThreshold = mu; 00196 } 00197 double GetKernelZeroMagnitudeThreshold() const 00198 { 00199 return m_KernelZeroMagnitudeThreshold; 00200 } 00202 00203 private: 00204 double m_NoisePowerSpectralDensityConstant; 00205 double m_KernelZeroMagnitudeThreshold; 00206 }; 00207 } //namespace Functor 00208 00209 } 00210 00211 #ifndef ITK_MANUAL_INSTANTIATION 00212 #include "itkWienerDeconvolutionImageFilter.hxx" 00213 #endif 00214 00215 #endif 00216
1.7.6.1