ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkTikhonovDeconvolutionImageFilter.h
Go to the documentation of this file.
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 __itkTikhonovDeconvolutionImageFilter_h
00019 #define __itkTikhonovDeconvolutionImageFilter_h
00020 
00021 #include "itkInverseDeconvolutionImageFilter.h"
00022 
00023 namespace itk
00024 {
00049 template< class TInputImage, class TKernelImage = TInputImage, class TOutputImage = TInputImage, class TInternalPrecision=double >
00050 class ITK_EXPORT TikhonovDeconvolutionImageFilter :
00051   public InverseDeconvolutionImageFilter< TInputImage, TKernelImage, TOutputImage, TInternalPrecision >
00052 {
00053 public:
00054   typedef TikhonovDeconvolutionImageFilter                      Self;
00055   typedef InverseDeconvolutionImageFilter< TInputImage,
00056                                            TKernelImage,
00057                                            TOutputImage,
00058                                            TInternalPrecision > Superclass;
00059   typedef SmartPointer< Self >                                  Pointer;
00060   typedef SmartPointer< const Self >                            ConstPointer;
00061 
00063   itkNewMacro(Self);
00064 
00066   itkTypeMacro(TikhonovDeconvolutionImageFilter, InverseDeconvolutionImageFilter);
00067 
00069   itkStaticConstMacro(ImageDimension, unsigned int,
00070                       TInputImage::ImageDimension);
00071 
00072   typedef TInputImage                           InputImageType;
00073   typedef TOutputImage                          OutputImageType;
00074   typedef TKernelImage                          KernelImageType;
00075   typedef typename Superclass::InputPixelType   InputPixelType;
00076   typedef typename Superclass::OutputPixelType  OutputPixelType;
00077   typedef typename Superclass::KernelPixelType  KernelPixelType;
00078   typedef typename Superclass::InputIndexType   InputIndexType;
00079   typedef typename Superclass::OutputIndexType  OutputIndexType;
00080   typedef typename Superclass::KernelIndexType  KernelIndexType;
00081   typedef typename Superclass::InputSizeType    InputSizeType;
00082   typedef typename Superclass::OutputSizeType   OutputSizeType;
00083   typedef typename Superclass::KernelSizeType   KernelSizeType;
00084   typedef typename Superclass::SizeValueType    SizeValueType;
00085   typedef typename Superclass::InputRegionType  InputRegionType;
00086   typedef typename Superclass::OutputRegionType OutputRegionType;
00087   typedef typename Superclass::KernelRegionType KernelRegionType;
00088 
00090   typedef typename Superclass::InternalImageType               InternalImageType;
00091   typedef typename Superclass::InternalImagePointerType        InternalImagePointerType;
00092   typedef typename Superclass::InternalComplexType             InternalComplexType;
00093   typedef typename Superclass::InternalComplexImageType        InternalComplexImageType;
00094   typedef typename Superclass::InternalComplexImagePointerType InternalComplexImagePointerType;
00095 
00100   itkSetMacro(RegularizationConstant, double);
00101   itkGetConstMacro(RegularizationConstant, double);
00103 
00104 protected:
00105   TikhonovDeconvolutionImageFilter();
00106   ~TikhonovDeconvolutionImageFilter() {}
00107 
00109   void GenerateData();
00110 
00111   virtual void PrintSelf(std::ostream & os, Indent indent) const;
00112 
00113 private:
00114   TikhonovDeconvolutionImageFilter(const Self &); //purposely not implemented
00115   void operator=(const Self &);                   //purposely not implemented
00116 
00117   double m_RegularizationConstant;
00118 };
00119 
00120 namespace Functor
00121 {
00122 template< class TInput1, class TInput2, class TOutput >
00123 class TikhonovDeconvolutionFunctor
00124 {
00125 public:
00126   TikhonovDeconvolutionFunctor() {m_RegularizationConstant = 0.0;}
00127   ~TikhonovDeconvolutionFunctor() {}
00128 
00129   bool operator!=( const TikhonovDeconvolutionFunctor & ) const
00130   {
00131     return false;
00132   }
00133   bool operator==( const TikhonovDeconvolutionFunctor & other) const
00134   {
00135     return !(*this != other);
00136   }
00137   inline TOutput operator()(const TInput1 & I, const TInput2 & H) const
00138   {
00139     typename TOutput::value_type normH = std::norm( H );
00140     typename TOutput::value_type denominator = normH + m_RegularizationConstant;
00141     TOutput value = NumericTraits< TOutput >::ZeroValue();
00142     if ( denominator >= m_KernelZeroMagnitudeThreshold )
00143       {
00144       value = static_cast< TOutput >( I * ( std::conj( H ) / denominator ) );
00145       }
00146 
00147     return value;
00148   }
00149 
00152   void SetRegularizationConstant(double constant)
00153   {
00154     m_RegularizationConstant = constant;
00155   }
00156   double GetRegularizationConstant() const
00157   {
00158     return m_RegularizationConstant;
00159   }
00161 
00164   void SetKernelZeroMagnitudeThreshold(double mu)
00165   {
00166     m_KernelZeroMagnitudeThreshold = mu;
00167   }
00168   double GetKernelZeroMagnitudeThreshold() const
00169   {
00170     return m_KernelZeroMagnitudeThreshold;
00171   }
00173 
00174 private:
00175   double m_RegularizationConstant;
00176   double m_KernelZeroMagnitudeThreshold;
00177 };
00178 } //namespace Functor
00179 
00180 }
00181 
00182 #ifndef ITK_MANUAL_INSTANTIATION
00183 #include "itkTikhonovDeconvolutionImageFilter.hxx"
00184 #endif
00185 
00186 #endif
00187