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: 2008-10-18 16:11:13 $
00007   Version:   $Revision: 1.26 $
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 __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 "itkNeighborhoodIterator.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 );
00078 
00079   const RadiusType &GetRadius() const
00080     { return m_Radius; }
00081   
00082   const unsigned int &GetArrayIndex(unsigned int i) const
00083     { return m_ArrayIndex[i]; }
00084 
00085   const OffsetType &GetNeighborhoodOffset(unsigned int i) const
00086     { return m_NeighborhoodOffset[i]; }
00087 
00088   const unsigned int &GetSize() const
00089     { return m_Size; }
00090 
00091   int GetStride(unsigned int i)
00092     { return m_StrideTable[i]; }
00093   
00094   SparseFieldCityBlockNeighborList();
00095   ~SparseFieldCityBlockNeighborList() {}
00096 
00097   void Print(std::ostream &os) const;
00098   
00099 private:
00100   unsigned int              m_Size;
00101   RadiusType                m_Radius;
00102   std::vector<unsigned int> m_ArrayIndex;
00103   std::vector<OffsetType>   m_NeighborhoodOffset;
00104 
00107   unsigned m_StrideTable[Dimension];
00108 };
00109 
00110   
00226 template <class TInputImage, class TOutputImage>
00227 class ITK_EXPORT SparseFieldLevelSetImageFilter :
00228   public FiniteDifferenceImageFilter<TInputImage, TOutputImage>
00229 {
00230 public:
00231 
00233   typedef SparseFieldLevelSetImageFilter                         Self;
00234   typedef FiniteDifferenceImageFilter<TInputImage, TOutputImage> Superclass;
00235   typedef SmartPointer<Self>                                     Pointer;
00236   typedef SmartPointer<const Self>                               ConstPointer;
00237 
00239   typedef typename Superclass::TimeStepType           TimeStepType;
00240   typedef typename Superclass::RadiusType             RadiusType;
00241   typedef typename Superclass::NeighborhoodScalesType NeighborhoodScalesType;
00242 
00244   itkNewMacro(Self);
00245 
00247   itkTypeMacro(SparseFieldLevelSetImageFilter, FiniteDifferenceImageFilter);
00248 
00250   typedef TInputImage                         InputImageType;
00251   typedef TOutputImage                        OutputImageType;
00252   typedef typename OutputImageType::IndexType IndexType;
00253   itkStaticConstMacro(ImageDimension, unsigned int,
00254                       TOutputImage::ImageDimension);
00255 
00258   typedef typename OutputImageType::ValueType ValueType;
00259 
00261   typedef SparseFieldLevelSetNode<IndexType> LayerNodeType;
00262 
00264   typedef SparseFieldLayer<LayerNodeType> LayerType;
00265   typedef typename LayerType::Pointer     LayerPointerType;
00266 
00268   typedef std::vector<LayerPointerType> LayerListType;
00269 
00271   typedef signed char StatusType;
00272 
00275   typedef Image<StatusType, itkGetStaticConstMacro(ImageDimension)>
00276   StatusImageType;
00277 
00280   typedef ObjectStore<LayerNodeType> LayerNodeStorageType;
00281 
00283   typedef std::vector<ValueType> UpdateBufferType;
00284 
00288   itkSetMacro(NumberOfLayers, unsigned int);
00289   itkGetMacro(NumberOfLayers, unsigned int);
00291 
00293   itkSetMacro(IsoSurfaceValue, ValueType);
00294   itkGetMacro(IsoSurfaceValue, ValueType);
00296 
00300   //  itkGetMacro(RMSChange, ValueType);
00301 
00307   itkSetMacro(InterpolateSurfaceLocation, bool);
00308   itkGetMacro(InterpolateSurfaceLocation, bool);
00310 
00312   void InterpolateSurfaceLocationOn()
00313     { this->SetInterpolateSurfaceLocation(true); }
00314   void InterpolateSurfaceLocationOff()
00315     { this->SetInterpolateSurfaceLocation(false); }
00317 
00318 #ifdef ITK_USE_CONCEPT_CHECKING
00319 
00320   itkConceptMacro(OutputEqualityComparableCheck,
00321     (Concept::EqualityComparable<typename TOutputImage::PixelType>));
00322   itkConceptMacro(DoubleConvertibleToOutputCheck,
00323     (Concept::Convertible<double, typename TOutputImage::PixelType>));
00324   itkConceptMacro(OutputOStreamWritableCheck,
00325     (Concept::OStreamWritable<typename TOutputImage::PixelType>));
00326 
00328 #endif
00329 
00330 protected:
00331   SparseFieldLevelSetImageFilter();
00332   ~SparseFieldLevelSetImageFilter();
00333   virtual void PrintSelf(std::ostream& os, Indent indent) const;
00334 
00339   inline virtual ValueType CalculateUpdateValue(
00340     const IndexType &itkNotUsed(idx),
00341     const TimeStepType &dt,
00342     const ValueType &value,
00343     const ValueType &change)
00344     { return (value + dt * change); }
00345 
00349   virtual void PostProcessOutput();
00350 
00355   virtual void InitializeBackgroundPixels();
00356 
00358   void Initialize();
00359 
00364   void CopyInputToOutput(); 
00365 
00367   void AllocateUpdateBuffer();
00368 
00371   void ApplyUpdate(TimeStepType dt);
00372 
00375   TimeStepType CalculateChange();
00376 
00380   void ConstructLayer(StatusType from, StatusType to);
00381 
00386   void ConstructActiveLayer();
00387 
00389   void InitializeActiveLayerValues();
00390 
00398   void PropagateLayerValues(StatusType from, StatusType to,
00399                             StatusType promote, int InOrOut);
00400 
00405   void PropagateAllLayerValues();
00406 
00410   void UpdateActiveLayerValues(TimeStepType dt, LayerType *StatusUpList,
00411                                LayerType *StatusDownList);
00412 
00414   void ProcessStatusList(LayerType *InputList, LayerType *OutputList,
00415                          StatusType ChangeToStatus, StatusType SearchForStatus);
00416 
00418   void ProcessOutsideList(LayerType *OutsideList, StatusType ChangeToStatus);
00419 
00420   itkGetConstMacro(ValueZero, ValueType);
00421   itkGetConstMacro(ValueOne, ValueType);
00422 
00424   SparseFieldCityBlockNeighborList<NeighborhoodIterator<OutputImageType> >
00425   m_NeighborList;
00426 
00429   double m_ConstantGradientValue;
00430 
00432   static ValueType m_ValueOne;
00433 
00435   static ValueType m_ValueZero;
00436 
00439   static StatusType m_StatusChanging;
00440 
00443   static StatusType m_StatusActiveChangingUp;
00444 
00447   static StatusType m_StatusActiveChangingDown;
00448 
00451   static StatusType m_StatusBoundaryPixel;
00452 
00455   static StatusType m_StatusNull;
00456 
00460   typename OutputImageType::Pointer m_ShiftedImage;
00461 
00466   LayerListType m_Layers;
00467 
00472   unsigned int m_NumberOfLayers;
00473 
00475   typename StatusImageType::Pointer m_StatusImage;
00476 
00478   typename LayerNodeStorageType::Pointer m_LayerNodeStore;
00479 
00481   ValueType m_IsoSurfaceValue;
00482 
00485   UpdateBufferType m_UpdateBuffer;
00486 
00490   //  ValueType m_RMSChange;  
00491 
00496   bool m_InterpolateSurfaceLocation;
00497 
00498 private:
00499   SparseFieldLevelSetImageFilter(const Self&);//purposely not implemented
00500   void operator=(const Self&);      //purposely not implemented
00501 
00504   bool m_BoundsCheckingActive;
00505 
00506 };
00507   
00508   
00509 } // end namespace itk
00510 
00511 #ifndef ITK_MANUAL_INSTANTIATION
00512 #include "itkSparseFieldLevelSetImageFilter.txx"
00513 #endif
00514 
00515 #endif
00516 

Generated at Thu Nov 6 00:16:29 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000