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: 2003/09/10 14:28:30 $
00007   Version:   $Revision: 1.27 $
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 _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 
00083 template <
00084   class TLevelSet, 
00085   class TSpeedImage = Image<float,::itk::GetImageDimension<TLevelSet>::ImageDimension> >
00086 class ITK_EXPORT FastMarchingImageFilter :
00087     public ImageToImageFilter<TSpeedImage,TLevelSet>
00088 {
00089 public:
00091   typedef FastMarchingImageFilter Self;
00092   typedef ImageSource<TLevelSet> Superclass;
00093   typedef SmartPointer<Self> Pointer;
00094   typedef SmartPointer<const Self>  ConstPointer;
00095 
00097   itkNewMacro(Self);
00098 
00100   itkTypeMacro(FastMarchingImageFilter, ImageSource);
00101 
00103   typedef LevelSetTypeDefault<TLevelSet>  LevelSetType;
00104   typedef typename LevelSetType::LevelSetImageType  LevelSetImageType;
00105   typedef typename LevelSetType::LevelSetPointer  LevelSetPointer;
00106   typedef typename LevelSetType::PixelType  PixelType;
00107   typedef typename LevelSetType::NodeType NodeType;
00108   typedef typename LevelSetType::NodeContainer NodeContainer;
00109   typedef typename LevelSetType::NodeContainerPointer NodeContainerPointer;
00110 
00112   itkStaticConstMacro(SetDimension, unsigned int,
00113                       LevelSetType::SetDimension);
00114 
00116   typedef Index<itkGetStaticConstMacro(SetDimension)> IndexType;
00117 
00119   typedef TSpeedImage SpeedImageType;
00120 
00122   typedef typename SpeedImageType::Pointer        SpeedImagePointer;
00123   typedef typename SpeedImageType::ConstPointer   SpeedImageConstPointer;
00124 
00129   enum LabelType { FarPoint, AlivePoint, TrialPoint };
00130 
00132   typedef Image<unsigned char, itkGetStaticConstMacro(SetDimension)> LabelImageType;
00133 
00135   typedef typename LabelImageType::Pointer LabelImagePointer;
00136 
00139   void SetAlivePoints( NodeContainer * points )
00140   { 
00141     m_AlivePoints = points; 
00142     this->Modified(); 
00143   };
00144 
00146   NodeContainerPointer GetAlivePoints( )
00147   { return m_AlivePoints; };
00148 
00151   void SetTrialPoints( NodeContainer * points )
00152   { 
00153     m_TrialPoints = points;
00154     this->Modified();
00155   };
00156 
00158   NodeContainerPointer GetTrialPoints( )
00159   { return m_TrialPoints; };
00160 
00162   LabelImagePointer GetLabelImage() const
00163   { return m_LabelImage; };
00164 
00168   void SetSpeedConstant( double value )
00169   {
00170     m_SpeedConstant = value;
00171     m_InverseSpeed = -1.0 * vnl_math_sqr( 1.0 / m_SpeedConstant );
00172     this->Modified();
00173   }
00174 
00176   itkGetConstMacro( SpeedConstant, double );
00177 
00182   itkSetMacro( NormalizationFactor, double );
00183   itkGetMacro( NormalizationFactor, double );
00184 
00188   itkSetMacro( StoppingValue, double );
00189 
00191   itkGetConstMacro( StoppingValue, double );
00192 
00197   itkSetMacro( CollectPoints, bool );
00198 
00200   itkGetConstMacro( CollectPoints, bool );
00201   itkBooleanMacro( CollectPoints );
00202 
00207   NodeContainerPointer GetProcessedPoints() const
00208   { return m_ProcessedPoints; }
00209 
00212   void SetOutputSize( const typename LevelSetImageType::SizeType& size )
00213   { m_OutputSize = size; }
00214 
00216   const typename LevelSetImageType::SizeType & GetOutputSize() const
00217   { return m_OutputSize; }
00218 
00219 protected:
00220   FastMarchingImageFilter();
00221   ~FastMarchingImageFilter(){};
00222   void PrintSelf( std::ostream& os, Indent indent ) const;
00223 
00224   virtual void Initialize( LevelSetImageType * );
00225   virtual void UpdateNeighbors( const IndexType& index, 
00226                                 const SpeedImageType *, LevelSetImageType * );
00227   virtual double UpdateValue( const IndexType& index, 
00228                               const SpeedImageType *, LevelSetImageType * );
00229 
00230 
00231   const NodeType& GetNodeUsedInCalculation(unsigned int idx) const
00232   { return m_NodesUsed[idx]; }
00233 
00234   void GenerateData();
00235 
00237   virtual void GenerateOutputInformation();
00238   virtual void EnlargeOutputRequestedRegion(DataObject *output);
00239 
00244   itkGetConstMacro( LargeValue, PixelType );
00245 
00246 
00247 private:
00248   FastMarchingImageFilter(const Self&); //purposely not implemented
00249   void operator=(const Self&); //purposely not implemented
00250   
00251   NodeContainerPointer                          m_AlivePoints;
00252   NodeContainerPointer                          m_TrialPoints;
00253 
00254   LabelImagePointer                             m_LabelImage;
00255   
00256   double                                        m_SpeedConstant;
00257   double                                        m_InverseSpeed;
00258   double                                        m_StoppingValue;
00259     
00260   bool                                          m_CollectPoints;
00261   NodeContainerPointer                          m_ProcessedPoints;
00262 
00263   typename LevelSetImageType::SizeType          m_OutputSize;
00264   typename LevelSetImageType::PixelType         m_LargeValue;
00265   NodeType                                      m_NodesUsed[SetDimension];
00266 
00270   typedef std::vector<NodeType> HeapContainer;
00271   typedef std::greater<NodeType> NodeComparer;
00272   typedef std::priority_queue< NodeType, HeapContainer, NodeComparer > HeapType;
00273 
00274   HeapType    m_TrialHeap;
00275 
00276   double    m_NormalizationFactor;
00277 };
00278 
00279 } // namespace itk
00280 
00281 
00282 #ifndef ITK_MANUAL_INSTANTIATION
00283 #include "itkFastMarchingImageFilter.txx"
00284 #endif
00285 
00286 #endif

Generated at Sun Jan 25 13:19:32 2004 for ITK by doxygen 1.3.3 written by Dimitri van Heesch, © 1997-2000