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

itkFastMarchingImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkFastMarchingImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2002/09/11 19:39:01 $
00007   Version:   $Revision: 1.19 $
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 _itkFastMarchingImageFilter_h
00018 #define _itkFastMarchingImageFilter_h
00019 
00020 #include "itkImageToImageFilter.h"
00021 #include "itkLevelSet.h"
00022 #include "itkIndex.h"
00023 #include "vnl/vnl_math.h"
00024 
00025 #include <functional>
00026 #include <queue>
00027 
00028 namespace itk
00029 {
00030 
00080 template <
00081   class TLevelSet, 
00082   class TSpeedImage = Image<float,::itk::GetImageDimension<TLevelSet>::ImageDimension> >
00083 class ITK_EXPORT FastMarchingImageFilter :
00084   public ImageToImageFilter<TSpeedImage,TLevelSet>
00085 {
00086 public:
00088   typedef FastMarchingImageFilter Self;
00089   typedef ImageSource<TLevelSet> Superclass;
00090   typedef SmartPointer<Self> Pointer;
00091   typedef SmartPointer<const Self>  ConstPointer;
00092 
00094   itkNewMacro(Self);
00095 
00097   itkTypeMacro(FastMarchingImageFilter, ImageSource);
00098 
00100   typedef LevelSetTypeDefault<TLevelSet>  LevelSetType;
00101   typedef typename LevelSetType::LevelSetImageType  LevelSetImageType;
00102   typedef typename LevelSetType::LevelSetPointer  LevelSetPointer;
00103   typedef typename LevelSetType::PixelType  PixelType;
00104   typedef typename LevelSetType::NodeType NodeType;
00105   typedef typename LevelSetType::NodeContainer NodeContainer;
00106   typedef typename LevelSetType::NodeContainerPointer NodeContainerPointer;
00107 
00109   itkStaticConstMacro(SetDimension, unsigned int,
00110                       LevelSetType::SetDimension);
00111 
00113   typedef Index<itkGetStaticConstMacro(SetDimension)> IndexType;
00114 
00116   typedef TSpeedImage SpeedImageType;
00117 
00119   typedef typename SpeedImageType::Pointer        SpeedImagePointer;
00120   typedef typename SpeedImageType::ConstPointer   SpeedImageConstPointer;
00121 
00126   enum LabelType { FarPoint, AlivePoint, TrialPoint };
00127 
00129   typedef Image<unsigned char, itkGetStaticConstMacro(SetDimension)> LabelImageType;
00130 
00132   typedef typename LabelImageType::Pointer LabelImagePointer;
00133 
00136   void SetAlivePoints( NodeContainer * points )
00137     { 
00138     m_AlivePoints = points; 
00139     this->Modified(); 
00140     };
00141 
00143   NodeContainerPointer GetAlivePoints( )
00144     { return m_AlivePoints; };
00145 
00148   void SetTrialPoints( NodeContainer * points )
00149     { 
00150     m_TrialPoints = points;
00151     this->Modified();
00152     };
00153 
00155   NodeContainerPointer GetTrialPoints( )
00156     { return m_TrialPoints; };
00157 
00160   void SetSpeedImage( const SpeedImageType * ptr );
00161 
00163   const SpeedImageType * GetSpeedImage(void);
00164 
00166   LabelImagePointer GetLabelImage() const
00167     { return m_LabelImage; };
00168 
00172   void SetSpeedConstant( double value )
00173     {
00174     m_SpeedConstant = value;
00175     m_InverseSpeed = -1.0 * vnl_math_sqr( 1.0 / m_SpeedConstant );
00176     this->Modified();
00177     }
00178 
00180   itkGetMacro( SpeedConstant, double );
00181 
00185   itkSetMacro( StoppingValue, double );
00186 
00188   itkGetMacro( StoppingValue, double );
00189 
00194   itkSetMacro( CollectPoints, bool );
00195 
00197   itkGetMacro( CollectPoints, double );
00198   itkBooleanMacro( CollectPoints );
00199 
00204   NodeContainerPointer GetProcessedPoints() const
00205     { return m_ProcessedPoints; }
00206 
00209   void SetOutputSize( const typename LevelSetImageType::SizeType& size )
00210     { m_OutputSize = size; }
00211 
00213   const typename LevelSetImageType::SizeType & GetOutputSize() const
00214     { return m_OutputSize; }
00215 
00216 protected:
00217   FastMarchingImageFilter();
00218   ~FastMarchingImageFilter(){};
00219   void PrintSelf( std::ostream& os, Indent indent ) const;
00220 
00221   virtual void Initialize( LevelSetImageType * );
00222   virtual void UpdateNeighbors( const IndexType& index, 
00223     const SpeedImageType *, LevelSetImageType * );
00224   virtual double UpdateValue( const IndexType& index, 
00225     const SpeedImageType *, LevelSetImageType * );
00226 
00227   typename LevelSetImageType::PixelType GetLargeValue() const
00228     { return m_LargeValue; }
00229 
00230   const NodeType& GetNodeUsedInCalculation(unsigned int idx) const
00231     { return m_NodesUsed[idx]; }
00232 
00233   void GenerateData();
00234 
00236   virtual void GenerateOutputInformation();
00237   virtual void EnlargeOutputRequestedRegion(DataObject *output);
00238 
00239 private:
00240   FastMarchingImageFilter(const Self&); //purposely not implemented
00241   void operator=(const Self&); //purposely not implemented
00242   
00243   NodeContainerPointer                          m_AlivePoints;
00244   NodeContainerPointer                          m_TrialPoints;
00245 
00246   LabelImagePointer                             m_LabelImage;
00247   
00248   double                                        m_SpeedConstant;
00249   double                                        m_InverseSpeed;
00250   double                                        m_StoppingValue;
00251     
00252   bool                                          m_CollectPoints;
00253   NodeContainerPointer                          m_ProcessedPoints;
00254 
00255   typename LevelSetImageType::SizeType          m_OutputSize;
00256   typename LevelSetImageType::PixelType         m_LargeValue;
00257   NodeType                                      m_NodesUsed[SetDimension];
00258 
00262   typedef std::vector<NodeType> HeapContainer;
00263   typedef std::greater<NodeType> NodeComparer;
00264   typedef std::priority_queue< NodeType, HeapContainer, NodeComparer > HeapType;
00265 
00266   HeapType    m_TrialHeap;
00267 
00268 };
00269 
00270 } // namespace itk
00271 
00272 
00273 #ifndef ITK_MANUAL_INSTANTIATION
00274 #include "itkFastMarchingImageFilter.txx"
00275 #endif
00276 
00277 #endif

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