ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkLevelSetEvolutionBase.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 
00019 
00020 #ifndef __itkLevelSetEvolutionBase_h
00021 #define __itkLevelSetEvolutionBase_h
00022 
00023 #include <list>
00024 
00025 #include "itkImage.h"
00026 #include "itkDiscreteLevelSetImageBase.h"
00027 #include "itkImageRegionIteratorWithIndex.h"
00028 #include "itkBinaryThresholdImageFilter.h"
00029 #include "itkSignedMaurerDistanceMapImageFilter.h"
00030 #include "itkNumericTraits.h"
00031 #include "itkLevelSetEvolutionStoppingCriterionBase.h"
00032 
00033 namespace itk
00034 {
00042 template< class TEquationContainer, class TLevelSet >
00043 class LevelSetEvolutionBase : public Object
00044 {
00045 public:
00046   typedef LevelSetEvolutionBase      Self;
00047   typedef SmartPointer< Self >       Pointer;
00048   typedef SmartPointer< const Self > ConstPointer;
00049   typedef Object                     Superclass;
00050 
00052   itkTypeMacro( LevelSetEvolutionBase, Object );
00053 
00054   typedef TEquationContainer                      EquationContainerType;
00055   typedef typename EquationContainerType::Pointer EquationContainerPointer;
00056   typedef typename EquationContainerType::TermContainerType
00057                                                   TermContainerType;
00058   typedef typename TermContainerType::Pointer     TermContainerPointer;
00059 
00060   typedef typename TermContainerType::TermType TermType;
00061   typedef typename TermType::Pointer           TermPointer;
00062 
00063   typedef typename TermContainerType::InputImageType InputImageType;
00064   typedef typename InputImageType::PixelType         InputImagePixelType;
00065   typedef typename InputImageType::ConstPointer      InputImageConstPointer;
00066   typedef typename InputImageType::RegionType        InputImageRegionType;
00067   typedef typename NumericTraits< InputImagePixelType >::RealType
00068                                                      InputPixelRealType;
00069 
00070   itkStaticConstMacro ( ImageDimension, unsigned int, InputImageType::ImageDimension );
00071 
00072   typedef typename TermContainerType::LevelSetContainerType       LevelSetContainerType;
00073 
00074   typedef typename LevelSetContainerType::LevelSetIdentifierType  LevelSetIdentifierType;
00075 
00076   typedef TLevelSet                               LevelSetType;
00077   typedef typename LevelSetType::InputType        LevelSetInputType;
00078   typedef typename LevelSetType::OutputType       LevelSetOutputType;
00079   typedef typename LevelSetType::OutputRealType   LevelSetOutputRealType;
00080   typedef typename LevelSetType::LevelSetDataType LevelSetDataType;
00081 
00082   typedef typename LevelSetContainerType::IdListType          IdListType;
00083   typedef typename LevelSetContainerType::IdListIterator      IdListIterator;
00084   typedef typename LevelSetContainerType::IdListConstIterator IdListConstIterator;
00085   typedef typename LevelSetContainerType::IdListImageType     IdListImageType;
00086   typedef typename LevelSetContainerType::CacheImageType      CacheImageType;
00087 
00088   typedef typename LevelSetContainerType::DomainMapImageFilterType DomainMapImageFilterType;
00089 
00090   typedef LevelSetEvolutionStoppingCriterionBase< LevelSetContainerType >
00091                                                   StoppingCriterionType;
00092   typedef typename StoppingCriterionType::Pointer StoppingCriterionPointer;
00093 
00094   itkSetObjectMacro( LevelSetContainer, LevelSetContainerType );
00095   itkGetObjectMacro( LevelSetContainer, LevelSetContainerType );
00096 
00098   itkSetMacro( Alpha, LevelSetOutputRealType );
00099   itkGetMacro( Alpha, LevelSetOutputRealType );
00101 
00103   void SetTimeStep( const LevelSetOutputRealType& iDt );
00104 
00106   itkSetObjectMacro( EquationContainer, EquationContainerType );
00107   itkGetObjectMacro( EquationContainer, EquationContainerType );
00109 
00111   itkGetObjectMacro( StoppingCriterion, StoppingCriterionType );
00112   itkSetObjectMacro( StoppingCriterion, StoppingCriterionType );
00114 
00116   itkSetMacro( NumberOfIterations, IdentifierType );
00117   itkGetConstMacro( NumberOfIterations, IdentifierType );
00119 
00123   void Update();
00124 
00125 protected:
00126   LevelSetEvolutionBase();
00127 
00128   virtual ~LevelSetEvolutionBase();
00129 
00130   void CheckSetUp();
00131 
00133   void InitializeIteration();
00134 
00139   void Evolve();
00140 
00143   virtual void AllocateUpdateBuffer();
00144 
00147   virtual void ComputeIteration();
00148 
00150   virtual void ComputeTimeStepForNextIteration();
00151 
00152   virtual void UpdateLevelSets() = 0;
00153 
00154   virtual void UpdateEquations() = 0;
00155 
00156   StoppingCriterionPointer    m_StoppingCriterion;
00157 
00158   EquationContainerPointer                 m_EquationContainer;
00159   typename LevelSetContainerType::Pointer  m_LevelSetContainer;
00160 
00161   LevelSetOutputRealType      m_Alpha;
00162   LevelSetOutputRealType      m_Dt;
00163   LevelSetOutputRealType      m_RMSChangeAccumulator;
00164   bool                        m_UserGloballyDefinedTimeStep;
00165   IdentifierType              m_NumberOfIterations;
00166 
00168   typename LevelSetContainerType::Iterator m_LevelSetContainerIteratorToProcessWhenThreading;
00169   typename LevelSetContainerType::Iterator m_LevelSetUpdateContainerIteratorToProcessWhenThreading;
00170 
00171 private:
00172   LevelSetEvolutionBase( const Self& ); // purposely not implemented
00173   void operator = ( const Self& );  // purposely not implemented
00174 };
00175 }
00176 
00177 #ifndef ITK_MANUAL_INSTANTIATION
00178 #include "itkLevelSetEvolutionBase.hxx"
00179 #endif
00180 
00181 #endif // __itkLevelSetEvolutionBase_h
00182