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