Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkAnisotropicDiffusionImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkAnisotropicDiffusionImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2002/09/11 19:39:01 $
00007   Version:   $Revision: 1.30 $
00008 
00009   Copyright (c) 2002 Insight Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkAnisotropicDiffusionImageFilter_h_
00018 #define __itkAnisotropicDiffusionImageFilter_h_
00019 
00020 #include "itkDenseFiniteDifferenceImageFilter.h"
00021 #include "itkAnisotropicDiffusionFunction.h"
00022 #include "itkNumericTraits.h"
00023 
00024 namespace itk {
00025 
00063 template <class TInputImage, class TOutputImage>
00064 class AnisotropicDiffusionImageFilter
00065   : public DenseFiniteDifferenceImageFilter<TInputImage, TOutputImage>
00066 {
00067 public:
00069   typedef AnisotropicDiffusionImageFilter Self;
00070   typedef DenseFiniteDifferenceImageFilter<TInputImage, TOutputImage>
00071    Superclass;
00072   typedef SmartPointer<Self> Pointer;
00073   typedef SmartPointer<const Self> ConstPointer;
00074 
00076   itkNewMacro(Self);
00077 
00079   itkTypeMacro(AnisotropicDiffusionImageFilter,
00080                DenseFiniteDifferenceImageFilter);
00081 
00083   typedef typename Superclass::InputImageType   InputImageType;
00084   typedef typename Superclass::OutputImageType  OutputImageType;
00085   typedef typename Superclass::UpdateBufferType UpdateBufferType;
00086 
00089   itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
00090 
00093   typedef typename Superclass::PixelType PixelType;
00094   typedef typename Superclass::TimeStepType TimeStepType;
00095 
00097   itkSetMacro(Iterations, unsigned int);
00098   itkGetMacro(Iterations, unsigned int);
00099 
00101   itkSetMacro(TimeStep, TimeStepType);
00102   itkGetMacro(TimeStep, TimeStepType);
00103 
00106   itkSetMacro(ConductanceParameter, double);
00107   itkGetMacro(ConductanceParameter, double);
00108 
00111   itkSetMacro(ConductanceScalingUpdateInterval, unsigned int);
00112   itkGetMacro(ConductanceScalingUpdateInterval, unsigned int);
00113   itkSetMacro(ConductanceScalingParameter, double);
00114   itkGetMacro(ConductanceScalingParameter, double);
00115 
00123   void SetFixedAverageGradientMagnitude(double a)
00124     {
00125       m_FixedAverageGradientMagnitude= a;
00126       this->Modified();
00127       m_GradientMagnitudeIsFixed = true;
00128     }
00129   itkGetMacro(FixedAverageGradientMagnitude, double);
00130   
00131 protected:
00132   AnisotropicDiffusionImageFilter()
00133     {
00134       m_Iterations = 0;
00135       m_ConductanceParameter = 1.0;
00136       m_TimeStep = 0.125f;
00137       m_FixedAverageGradientMagnitude = 0.0;
00138       m_GradientMagnitudeIsFixed = false;
00139     }
00140   ~AnisotropicDiffusionImageFilter() {}
00141   void PrintSelf(std::ostream& os, Indent indent) const
00142     {
00143       Superclass::PrintSelf(os, indent.GetNextIndent());
00144       os << indent << "TimeStep: " << m_TimeStep << std::endl;
00145       os << indent << "ConductanceParameter: "
00146          << m_ConductanceParameter << std::endl;
00147       os << indent << "ConductanceScalingParameter: "
00148          << m_ConductanceScalingParameter << std::endl;
00149       os << indent << "Iterations: " << m_Iterations
00150          << std::endl;
00151       os << indent << "ConductanceScalingUpdateInterval: "
00152          << m_ConductanceScalingUpdateInterval << std::endl;
00153       os << indent << "FixedAverageGradientMagnitude: "
00154          << m_FixedAverageGradientMagnitude << std::endl;
00155     }
00156   
00159   virtual bool Halt()
00160     {
00161       if (this->GetElapsedIterations() == m_Iterations) return true;
00162       else return false;
00163     }
00164 
00166   virtual void InitializeIteration()
00167     {
00168       AnisotropicDiffusionFunction<UpdateBufferType> *f = 
00169         dynamic_cast<AnisotropicDiffusionFunction<UpdateBufferType> *>
00170         (this->GetDifferenceFunction().GetPointer());
00171       if (! f)
00172         {  throw ExceptionObject(__FILE__, __LINE__);    }
00173       
00174       f->SetConductanceParameter(m_ConductanceParameter);
00175       
00176       if (m_GradientMagnitudeIsFixed == false)
00177         {
00178           f->CalculateAverageGradientMagnitudeSquared(this->GetOutput());
00179         }
00180       else
00181         {
00182           f->SetAverageGradientMagnitudeSquared(m_FixedAverageGradientMagnitude 
00183                                                 *
00184                                                 m_FixedAverageGradientMagnitude);
00185         }
00186       f->InitializeIteration();
00187 
00188       if (m_Iterations != 0)
00189           this->UpdateProgress(((float)(this->GetElapsedIterations()))
00190                                /((float)(m_Iterations)));
00191       else this->UpdateProgress(0);
00192     }
00193 
00194   bool m_GradientMagnitudeIsFixed;
00195   
00196 private:
00197   AnisotropicDiffusionImageFilter(const Self&); //purposely not implemented
00198   void operator=(const Self&); //purposely not implemented
00199   
00200   double           m_ConductanceParameter;
00201   double           m_ConductanceScalingParameter;
00202   unsigned int     m_Iterations;
00203   unsigned int     m_ConductanceScalingUpdateInterval;
00204   double           m_FixedAverageGradientMagnitude;
00205 
00206   TimeStepType     m_TimeStep;
00207   
00208 };
00209 
00210 } // end namspace itk
00211 
00212 #endif

Generated at Wed Mar 12 01:12:47 2003 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000