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

itkSparseFieldFourthOrderLevelSetImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkSparseFieldFourthOrderLevelSetImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2008-10-18 16:11:13 $
00007   Version:   $Revision: 1.16 $
00008 
00009   Copyright (c) Insight Software 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 __itkSparseFieldFourthOrderLevelSetImageFilter_h
00018 #define __itkSparseFieldFourthOrderLevelSetImageFilter_h
00019 
00020 #include "itkSparseImage.h"
00021 #include "itkNormalVectorDiffusionFunction.h"
00022 #include "itkImplicitManifoldNormalVectorFilter.h"
00023 #include "itkLevelSetFunctionWithRefitTerm.h"
00024 #include "itkSparseFieldLevelSetImageFilter.h"
00025 #include <math.h>
00026 
00027 namespace itk {
00028 
00036 template <class TImageType>
00037 class NormalBandNode
00038 {
00039 public:
00040 
00042   typedef TImageType LevelSetImageType;
00043 
00045   typedef typename LevelSetImageType::PixelType  NodeValueType;
00046 
00048   typedef typename LevelSetImageType::IndexType  IndexType;
00049 
00051   typedef Vector <NodeValueType,
00052                   ::itk::GetImageDimension<TImageType>::ImageDimension>
00053   NodeDataType;
00054 
00056   NodeDataType m_Data;
00057 
00059   NodeDataType m_InputData;
00060 
00062   NodeDataType m_Update;
00063 
00066   NodeDataType
00067   m_ManifoldNormal[::itk::GetImageDimension<TImageType>::ImageDimension];
00068 
00070   NodeDataType m_Flux [::itk::GetImageDimension<TImageType>::ImageDimension];
00071 
00074   NodeValueType m_Curvature;
00075 
00078   bool          m_CurvatureFlag;
00079 
00081   IndexType m_Index;  
00082 
00084   NormalBandNode *Next;  
00085   NormalBandNode *Previous;
00086 };
00087 
00154 template <class TInputImage, class TOutputImage>
00155 class ITK_EXPORT SparseFieldFourthOrderLevelSetImageFilter
00156   : public SparseFieldLevelSetImageFilter <TInputImage, TOutputImage>
00157 {
00158 public:
00159 
00161   typedef SparseFieldFourthOrderLevelSetImageFilter                 Self;
00162   typedef SparseFieldLevelSetImageFilter<TInputImage, TOutputImage> Superclass;
00163   typedef SmartPointer<Self>                                        Pointer;
00164   typedef SmartPointer<const Self>                                  ConstPointer;
00165 
00167   itkTypeMacro(SparseFieldFourthOrderLevelSetImageFilter,
00168                SparseFieldLevelSetImageFilter);
00169 
00171   itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
00172 
00174   typedef typename Superclass::OutputImageType        OutputImageType;
00175   typedef typename Superclass::ValueType              ValueType;
00176   typedef typename Superclass::IndexType              IndexType;
00177   typedef typename Superclass::LayerType              LayerType;
00178   typedef typename Superclass::RadiusType             RadiusType;
00179   typedef typename Superclass::NeighborhoodScalesType NeighborhoodScalesType;
00180 
00183   typedef NormalBandNode <OutputImageType> NodeType;
00184 
00186   typedef SparseImage <NodeType,
00187                        itkGetStaticConstMacro(ImageDimension)> SparseImageType;
00188 
00190   typedef typename NodeType::NodeDataType NormalVectorType;
00191 
00193   typedef NeighborhoodIterator <SparseImageType> SparseImageIteratorType;
00194 
00196   typedef ImplicitManifoldNormalVectorFilter <OutputImageType, SparseImageType>
00197   NormalVectorFilterType;
00198 
00200   typedef NormalVectorDiffusionFunction <SparseImageType>
00201   NormalVectorFunctionType;
00202 
00204   //typedef typename NormalVectorFunctionType::RadiusType RadiusType;
00205 
00207   typedef LevelSetFunctionWithRefitTerm <OutputImageType,
00208                                          SparseImageType> LevelSetFunctionType; 
00209 
00210   itkGetConstReferenceMacro(MaxRefitIteration,unsigned int);
00211   itkSetMacro(MaxRefitIteration,unsigned int);
00212   itkGetConstReferenceMacro(MaxNormalIteration,unsigned int);
00213   itkSetMacro(MaxNormalIteration,unsigned int);
00214   itkGetConstReferenceMacro(CurvatureBandWidth,ValueType);
00215   itkSetMacro(CurvatureBandWidth,ValueType);
00216   itkGetConstReferenceMacro(RMSChangeNormalProcessTrigger, ValueType);
00217   itkSetMacro(RMSChangeNormalProcessTrigger, ValueType);
00218   itkGetConstReferenceMacro(NormalProcessType, int);
00219   itkSetMacro(NormalProcessType, int);
00220   itkGetConstReferenceMacro(NormalProcessConductance, ValueType);
00221   itkSetMacro(NormalProcessConductance, ValueType);
00222   itkSetMacro(NormalProcessUnsharpFlag, bool);
00223   itkGetConstReferenceMacro(NormalProcessUnsharpFlag, bool);
00224   itkSetMacro(NormalProcessUnsharpWeight, ValueType);
00225   itkGetConstReferenceMacro(NormalProcessUnsharpWeight, ValueType);
00226 
00229   void SetLevelSetFunction( LevelSetFunctionType *lsf );
00230 
00234   unsigned int GetMinimumNumberOfLayers() const
00235     {
00236     return (int)vcl_ceil(m_CurvatureBandWidth+
00237                      itkGetStaticConstMacro(ImageDimension));
00238     }
00239 
00242   virtual void SetNumberOfLayers( const unsigned int n )
00243     {
00244     unsigned int nm = vnl_math_max (this->GetMinimumNumberOfLayers (), n );
00245     if (nm != this->GetNumberOfLayers())
00246       {
00247       Superclass::SetNumberOfLayers (nm);
00248       this->Modified();
00249       }
00250     }
00252 
00255   virtual void InitializeIteration()
00256     {
00257     Superclass::InitializeIteration();
00258     ValueType rmschange = this->GetRMSChange();
00260 
00261     if ( ( this->GetElapsedIterations() == 0 ) ||
00262          ( m_RefitIteration == m_MaxRefitIteration ) ||
00263          ( rmschange <= m_RMSChangeNormalProcessTrigger ) ||
00264          ( this->ActiveLayerCheckBand() ) )
00265       {
00266       if ( ( this->GetElapsedIterations() != 0 ) &&
00267            ( rmschange <= m_RMSChangeNormalProcessTrigger ) &&
00268            ( m_RefitIteration <= 1) )
00269         {
00270         m_ConvergenceFlag = true;
00271         }
00272 
00273       m_RefitIteration = 0;
00274       ProcessNormals();
00275       }
00276     
00277     m_RefitIteration++;
00278     }
00279 
00280 #ifdef ITK_USE_CONCEPT_CHECKING
00281 
00282   itkConceptMacro(OutputHasNumericTraitsCheck,
00283                   (Concept::HasNumericTraits<ValueType>));
00284 
00286 #endif
00287 
00288 protected:
00289   SparseFieldFourthOrderLevelSetImageFilter();
00290   ~SparseFieldFourthOrderLevelSetImageFilter() {};
00291   virtual void PrintSelf(std::ostream& os, Indent indent) const;
00292 
00293 
00296   ValueType ComputeCurvatureFromSparseImageNeighborhood
00297   ( SparseImageIteratorType &neighborhood ) const;
00298 
00302   void ComputeCurvatureTarget( const OutputImageType *distanceImage,
00303                                SparseImageType *sparseImage ) const;
00304 
00306   void ProcessNormals();
00307 
00312   bool ActiveLayerCheckBand() const;
00313 
00314 private:
00317   unsigned int m_RefitIteration;
00318 
00322   unsigned int m_MaxRefitIteration;
00323 
00326   unsigned int m_MaxNormalIteration;
00327 
00331   ValueType m_RMSChangeNormalProcessTrigger;
00332 
00335   bool m_ConvergenceFlag;
00336 
00339   LevelSetFunctionType *m_LevelSetFunction;
00340 
00345   ValueType m_CurvatureBandWidth;
00346 
00349   int m_NormalProcessType;
00350 
00353   ValueType m_NormalProcessConductance;
00354 
00357   bool m_NormalProcessUnsharpFlag;
00358 
00361   ValueType m_NormalProcessUnsharpWeight;
00362 
00364   static const unsigned long m_NumVertex;
00365   static const ValueType     m_DimConst;
00366 
00367   SparseFieldFourthOrderLevelSetImageFilter(const Self&);
00368   //purposely not implemented
00369   void operator=(const Self&); //purposely not implemented
00370 };
00371 
00372 } // end namespace itk
00373 
00374 #ifndef ITK_MANUAL_INSTANTIATION
00375 #include "itkSparseFieldFourthOrderLevelSetImageFilter.txx"
00376 #endif
00377 
00378 #endif
00379 

Generated at Tue Sep 15 05:00:53 2009 for ITK by doxygen 1.5.8 written by Dimitri van Heesch, © 1997-2000