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

itkSparseFieldLevelSetImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkSparseFieldLevelSetImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2002/09/24 16:48:17 $
00007   Version:   $Revision: 1.11 $
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 __itkSparseFieldLevelSetImageFilter_h_
00018 #define __itkSparseFieldLevelSetImageFilter_h_
00019 
00020 #include "itkFiniteDifferenceImageFilter.h"
00021 #include "itkMultiThreader.h"
00022 #include "itkSparseFieldLayer.h"
00023 #include "itkObjectStore.h"
00024 #include <vector>
00025 #include "itkSmartNeighborhoodIterator.h"
00026 
00027 namespace itk {
00028 
00033 template <class TValueType>
00034 class SparseFieldLevelSetNode
00035 {
00036 public:
00037   TValueType m_Value;
00038   SparseFieldLevelSetNode *Next;
00039   SparseFieldLevelSetNode *Previous;
00040 };
00041 
00068 template <class TNeighborhoodType>
00069 class SparseFieldCityBlockNeighborList
00070 {
00071 public:
00072   typedef TNeighborhoodType NeighborhoodType;
00073   typedef typename NeighborhoodType::OffsetType OffsetType;
00074   typedef typename NeighborhoodType::RadiusType RadiusType;
00075   itkStaticConstMacro(Dimension, unsigned int,
00076                       NeighborhoodType::Dimension );
00077 
00078   const RadiusType &GetRadius() const
00079   { return m_Radius; }
00080   
00081   const unsigned int &GetArrayIndex(unsigned int i) const
00082   { return m_ArrayIndex[i]; }
00083 
00084   const OffsetType &GetNeighborhoodOffset(unsigned int i) const
00085   { return m_NeighborhoodOffset[i]; }
00086 
00087   const unsigned int &GetSize() const
00088   { return m_Size; }
00089   
00090   SparseFieldCityBlockNeighborList();
00091   ~SparseFieldCityBlockNeighborList() {}
00092 
00093   void Print(std::ostream &os) const;
00094   
00095 private:
00096   unsigned int m_Size;
00097   RadiusType m_Radius;
00098   std::vector<unsigned int> m_ArrayIndex;
00099   std::vector<OffsetType>   m_NeighborhoodOffset;
00100 };
00101 
00102   
00218 template <class TInputImage, class TOutputImage>
00219 class ITK_EXPORT SparseFieldLevelSetImageFilter :
00220     public FiniteDifferenceImageFilter<TInputImage, TOutputImage>
00221 {
00222 public:
00224   typedef SparseFieldLevelSetImageFilter  Self;
00225   typedef FiniteDifferenceImageFilter<TInputImage, TOutputImage> Superclass;
00226   typedef SmartPointer<Self>  Pointer;
00227   typedef SmartPointer<const Self>  ConstPointer;
00228 
00230   typedef typename Superclass::TimeStepType TimeStepType;
00231   
00233   itkNewMacro(Self);
00234 
00236   itkTypeMacro(SparseFieldLevelSetImageFilter, FiniteDifferenceImageFilter);
00237 
00239   typedef TInputImage  InputImageType;
00240   typedef TOutputImage OutputImageType;
00241   typedef typename OutputImageType::IndexType IndexType;
00242   itkStaticConstMacro(ImageDimension, unsigned int,
00243                       TOutputImage::ImageDimension);
00244 
00247   typedef typename OutputImageType::ValueType ValueType;
00248 
00250   typedef SparseFieldLevelSetNode<IndexType> LayerNodeType;
00251   
00253   typedef SparseFieldLayer<LayerNodeType> LayerType;
00254   typedef typename LayerType::Pointer LayerPointerType;
00255 
00257   typedef std::vector<LayerPointerType> LayerListType;
00258   
00260   typedef char StatusType;
00261   
00264   typedef Image<StatusType, itkGetStaticConstMacro(ImageDimension)>
00265     StatusImageType;
00266 
00269   typedef ObjectStore<LayerNodeType> LayerNodeStorageType;
00270 
00272   typedef std::vector<ValueType> UpdateBufferType;
00273 
00277   itkSetMacro(NumberOfLayers, unsigned int);
00278   itkGetMacro(NumberOfLayers, unsigned int);
00279 
00281   itkSetMacro(IsoSurfaceValue, ValueType);
00282   itkGetMacro(IsoSurfaceValue, ValueType);
00283 
00287   itkGetMacro(RMSChange, ValueType);
00288     
00289 protected:
00290   SparseFieldLevelSetImageFilter();
00291   ~SparseFieldLevelSetImageFilter();
00292   virtual void PrintSelf(std::ostream& os, Indent indent) const;
00293 
00298   inline virtual ValueType CalculateUpdateValue(const IndexType &idx,
00299                                          const TimeStepType &dt,
00300                                          const ValueType &value,
00301                                          const ValueType &change)
00302   { return (value + dt * change); }
00303 
00307   virtual void PostProcessOutput();
00308 
00313   virtual void InitializeBackgroundPixels();
00314  
00316   void Initialize();
00317 
00322   void CopyInputToOutput(); 
00323 
00325   void AllocateUpdateBuffer();
00326 
00329   void ApplyUpdate(TimeStepType dt);
00330 
00333   TimeStepType CalculateChange();
00334 
00338   void ConstructLayer(StatusType from, StatusType to);
00339 
00344   void ConstructActiveLayer();
00345 
00347   void InitializeActiveLayerValues();
00348   
00356   void PropagateLayerValues(StatusType from, StatusType to,
00357                             StatusType promote, int InOrOut);
00358 
00363   void PropagateAllLayerValues();
00364 
00368   void UpdateActiveLayerValues(TimeStepType dt, LayerType *StatusUpList,
00369                                LayerType *StatusDownList);
00371   void ProcessStatusList(LayerType *InputList, LayerType *OutputList,
00372                          StatusType ChangeToStatus, StatusType SearchForStatus);
00373 
00375   void ProcessOutsideList(LayerType *OutsideList, StatusType ChangeToStatus);
00376   
00378   SparseFieldCityBlockNeighborList<SmartNeighborhoodIterator<OutputImageType> >
00379     m_NeighborList;
00380   
00383   static double m_ConstantGradientValue;
00384 
00386   static ValueType m_ValueOne;
00387 
00389   static ValueType m_ValueZero;
00390 
00393   static StatusType m_StatusChanging;
00394 
00397   static StatusType m_StatusActiveChangingUp;
00398 
00401   static StatusType m_StatusActiveChangingDown;
00402 
00405   static StatusType m_StatusNull;
00406     
00410   typename OutputImageType::Pointer m_ShiftedImage;
00411 
00416   LayerListType m_Layers;
00417 
00421   unsigned int m_NumberOfLayers;
00422 
00424   typename StatusImageType::Pointer m_StatusImage;
00425 
00427   typename LayerNodeStorageType::Pointer m_LayerNodeStore;
00428   
00430   ValueType m_IsoSurfaceValue;
00431 
00434   UpdateBufferType m_UpdateBuffer;
00435 
00439   ValueType m_RMSChange;  
00440 
00441 private:
00442   SparseFieldLevelSetImageFilter(const Self&);//purposely not implemented
00443   void operator=(const Self&);      //purposely not implemented
00444 
00445 };
00446   
00447   
00448 } // end namespace itk
00449 
00450 #ifndef ITK_MANUAL_INSTANTIATION
00451 #include "itkSparseFieldLevelSetImageFilter.txx"
00452 #endif
00453 
00454 #endif

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