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/01/23 03:05:09 $
00007   Version:   $Revision: 1.20 $
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 
00082 template <
00083   class TLevelSet, 
00084   class TSpeedImage = Image<float,::itk::GetImageDimension<TLevelSet>::ImageDimension> >
00085 class ITK_EXPORT FastMarchingImageFilter :
00086   public ImageToImageFilter<TSpeedImage,TLevelSet>
00087 {
00088 public:
00090   typedef FastMarchingImageFilter Self;
00091   typedef ImageSource<TLevelSet> Superclass;
00092   typedef SmartPointer<Self> Pointer;
00093   typedef SmartPointer<const Self>  ConstPointer;
00094 
00096   itkNewMacro(Self);
00097 
00099   itkTypeMacro(FastMarchingImageFilter, ImageSource);
00100 
00102   typedef LevelSetTypeDefault<TLevelSet>  LevelSetType;
00103   typedef typename LevelSetType::LevelSetImageType  LevelSetImageType;
00104   typedef typename LevelSetType::LevelSetPointer  LevelSetPointer;
00105   typedef typename LevelSetType::PixelType  PixelType;
00106   typedef typename LevelSetType::NodeType NodeType;
00107   typedef typename LevelSetType::NodeContainer NodeContainer;
00108   typedef typename LevelSetType::NodeContainerPointer NodeContainerPointer;
00109 
00111   itkStaticConstMacro(SetDimension, unsigned int,
00112                       LevelSetType::SetDimension);
00113 
00115   typedef Index<itkGetStaticConstMacro(SetDimension)> IndexType;
00116 
00118   typedef TSpeedImage SpeedImageType;
00119 
00121   typedef typename SpeedImageType::Pointer        SpeedImagePointer;
00122   typedef typename SpeedImageType::ConstPointer   SpeedImageConstPointer;
00123 
00128   enum LabelType { FarPoint, AlivePoint, TrialPoint };
00129 
00131   typedef Image<unsigned char, itkGetStaticConstMacro(SetDimension)> LabelImageType;
00132 
00134   typedef typename LabelImageType::Pointer LabelImagePointer;
00135 
00138   void SetAlivePoints( NodeContainer * points )
00139     { 
00140     m_AlivePoints = points; 
00141     this->Modified(); 
00142     };
00143 
00145   NodeContainerPointer GetAlivePoints( )
00146     { return m_AlivePoints; };
00147 
00150   void SetTrialPoints( NodeContainer * points )
00151     { 
00152     m_TrialPoints = points;
00153     this->Modified();
00154     };
00155 
00157   NodeContainerPointer GetTrialPoints( )
00158     { return m_TrialPoints; };
00159 
00161   LabelImagePointer GetLabelImage() const
00162     { return m_LabelImage; };
00163 
00167   void SetSpeedConstant( double value )
00168     {
00169     m_SpeedConstant = value;
00170     m_InverseSpeed = -1.0 * vnl_math_sqr( 1.0 / m_SpeedConstant );
00171     this->Modified();
00172     }
00173 
00175   itkGetMacro( SpeedConstant, double );
00176 
00180   itkSetMacro( StoppingValue, double );
00181 
00183   itkGetMacro( StoppingValue, double );
00184 
00189   itkSetMacro( CollectPoints, bool );
00190 
00192   itkGetMacro( CollectPoints, double );
00193   itkBooleanMacro( CollectPoints );
00194 
00199   NodeContainerPointer GetProcessedPoints() const
00200     { return m_ProcessedPoints; }
00201 
00204   void SetOutputSize( const typename LevelSetImageType::SizeType& size )
00205     { m_OutputSize = size; }
00206 
00208   const typename LevelSetImageType::SizeType & GetOutputSize() const
00209     { return m_OutputSize; }
00210 
00211 protected:
00212   FastMarchingImageFilter();
00213   ~FastMarchingImageFilter(){};
00214   void PrintSelf( std::ostream& os, Indent indent ) const;
00215 
00216   virtual void Initialize( LevelSetImageType * );
00217   virtual void UpdateNeighbors( const IndexType& index, 
00218     const SpeedImageType *, LevelSetImageType * );
00219   virtual double UpdateValue( const IndexType& index, 
00220     const SpeedImageType *, LevelSetImageType * );
00221 
00222   typename LevelSetImageType::PixelType GetLargeValue() const
00223     { return m_LargeValue; }
00224 
00225   const NodeType& GetNodeUsedInCalculation(unsigned int idx) const
00226     { return m_NodesUsed[idx]; }
00227 
00228   void GenerateData();
00229 
00231   virtual void GenerateOutputInformation();
00232   virtual void EnlargeOutputRequestedRegion(DataObject *output);
00233 
00234 private:
00235   FastMarchingImageFilter(const Self&); //purposely not implemented
00236   void operator=(const Self&); //purposely not implemented
00237   
00238   NodeContainerPointer                          m_AlivePoints;
00239   NodeContainerPointer                          m_TrialPoints;
00240 
00241   LabelImagePointer                             m_LabelImage;
00242   
00243   double                                        m_SpeedConstant;
00244   double                                        m_InverseSpeed;
00245   double                                        m_StoppingValue;
00246     
00247   bool                                          m_CollectPoints;
00248   NodeContainerPointer                          m_ProcessedPoints;
00249 
00250   typename LevelSetImageType::SizeType          m_OutputSize;
00251   typename LevelSetImageType::PixelType         m_LargeValue;
00252   NodeType                                      m_NodesUsed[SetDimension];
00253 
00257   typedef std::vector<NodeType> HeapContainer;
00258   typedef std::greater<NodeType> NodeComparer;
00259   typedef std::priority_queue< NodeType, HeapContainer, NodeComparer > HeapType;
00260 
00261   HeapType    m_TrialHeap;
00262 
00263 };
00264 
00265 } // namespace itk
00266 
00267 
00268 #ifndef ITK_MANUAL_INSTANTIATION
00269 #include "itkFastMarchingImageFilter.txx"
00270 #endif
00271 
00272 #endif

Generated at Fri May 21 01:14:41 2004 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000