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: 2005/04/17 18:40:58 $
00007   Version:   $Revision: 1.33 $
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 
00095 template <
00096   class TLevelSet, 
00097   class TSpeedImage = Image<float,::itk::GetImageDimension<TLevelSet>::ImageDimension> >
00098 class ITK_EXPORT FastMarchingImageFilter :
00099     public ImageToImageFilter<TSpeedImage,TLevelSet>
00100 {
00101 public:
00103   typedef FastMarchingImageFilter Self;
00104   typedef ImageSource<TLevelSet> Superclass;
00105   typedef SmartPointer<Self> Pointer;
00106   typedef SmartPointer<const Self>  ConstPointer;
00107 
00109   itkNewMacro(Self);
00110 
00112   itkTypeMacro(FastMarchingImageFilter, ImageSource);
00113 
00115   typedef LevelSetTypeDefault<TLevelSet>  LevelSetType;
00116   typedef typename LevelSetType::LevelSetImageType  LevelSetImageType;
00117   typedef typename LevelSetType::LevelSetPointer  LevelSetPointer;
00118   typedef typename LevelSetType::PixelType  PixelType;
00119   typedef typename LevelSetType::NodeType NodeType;
00120   typedef typename LevelSetType::NodeContainer NodeContainer;
00121   typedef typename LevelSetType::NodeContainerPointer NodeContainerPointer;
00122   typedef typename LevelSetImageType::SizeType    OutputSizeType;
00123   typedef typename LevelSetImageType::RegionType  OutputRegionType;
00124   typedef typename LevelSetImageType::SpacingType OutputSpacingType;
00125   typedef typename LevelSetImageType::PointType   OutputPointType;
00126 
00127   class AxisNodeType : public NodeType
00128   {
00129   public:
00130     int GetAxis() const { return m_Axis; }
00131     void SetAxis( int axis ) { m_Axis = axis; }
00132     const AxisNodeType & operator=(const NodeType & node)
00133                           { this->NodeType::operator=(node); return *this; }
00134   private:
00135     int m_Axis;
00136   };
00137 
00139   itkStaticConstMacro(SetDimension, unsigned int,
00140                       LevelSetType::SetDimension);
00141 
00143   typedef Index<itkGetStaticConstMacro(SetDimension)> IndexType;
00144 
00146   typedef TSpeedImage SpeedImageType;
00147 
00149   typedef typename SpeedImageType::Pointer        SpeedImagePointer;
00150   typedef typename SpeedImageType::ConstPointer   SpeedImageConstPointer;
00151 
00156   enum LabelType { FarPoint, AlivePoint, TrialPoint };
00157 
00159   typedef Image<unsigned char, itkGetStaticConstMacro(SetDimension)> LabelImageType;
00160 
00162   typedef typename LabelImageType::Pointer LabelImagePointer;
00163 
00166   void SetAlivePoints( NodeContainer * points )
00167   { 
00168     m_AlivePoints = points; 
00169     this->Modified(); 
00170   };
00171 
00173   NodeContainerPointer GetAlivePoints( )
00174   { return m_AlivePoints; };
00175 
00178   void SetTrialPoints( NodeContainer * points )
00179   { 
00180     m_TrialPoints = points;
00181     this->Modified();
00182   };
00183 
00185   NodeContainerPointer GetTrialPoints( )
00186   { return m_TrialPoints; };
00187 
00189   LabelImagePointer GetLabelImage() const
00190   { return m_LabelImage; };
00191 
00195   void SetSpeedConstant( double value )
00196   {
00197     m_SpeedConstant = value;
00198     m_InverseSpeed = -1.0 * vnl_math_sqr( 1.0 / m_SpeedConstant );
00199     this->Modified();
00200   }
00201 
00203   itkGetConstReferenceMacro( SpeedConstant, double );
00204 
00209   itkSetMacro( NormalizationFactor, double );
00210   itkGetMacro( NormalizationFactor, double );
00211 
00215   itkSetMacro( StoppingValue, double );
00216 
00218   itkGetConstReferenceMacro( StoppingValue, double );
00219 
00224   itkSetMacro( CollectPoints, bool );
00225 
00227   itkGetConstReferenceMacro( CollectPoints, bool );
00228   itkBooleanMacro( CollectPoints );
00229 
00234   NodeContainerPointer GetProcessedPoints() const
00235   { return m_ProcessedPoints; }
00236 
00237 
00244   virtual void SetOutputSize( const OutputSizeType& size )
00245   { m_OutputRegion = size; }
00246   virtual OutputSizeType GetOutputSize() const
00247   { return m_OutputRegion.GetSize(); }
00248   itkSetMacro( OutputRegion, OutputRegionType );
00249   itkGetConstReferenceMacro( OutputRegion, OutputRegionType );
00250   itkSetMacro( OutputSpacing, OutputSpacingType );
00251   itkGetConstReferenceMacro( OutputSpacing, OutputSpacingType );
00252   itkSetMacro( OutputOrigin, OutputPointType );
00253   itkGetConstReferenceMacro( OutputOrigin, OutputPointType );
00254   itkSetMacro( OverrideOutputInformation, bool );
00255   itkGetConstReferenceMacro( OverrideOutputInformation, bool );
00256   itkBooleanMacro( OverrideOutputInformation );
00257 
00258 protected:
00259   FastMarchingImageFilter();
00260   ~FastMarchingImageFilter(){};
00261   void PrintSelf( std::ostream& os, Indent indent ) const;
00262 
00263   virtual void Initialize( LevelSetImageType * );
00264   virtual void UpdateNeighbors( const IndexType& index, 
00265                                 const SpeedImageType *, LevelSetImageType * );
00266   virtual double UpdateValue( const IndexType& index, 
00267                               const SpeedImageType *, LevelSetImageType * );
00268 
00269 
00270   const AxisNodeType& GetNodeUsedInCalculation(unsigned int idx) const
00271   { return m_NodesUsed[idx]; }
00272 
00273   void GenerateData();
00274 
00276   virtual void GenerateOutputInformation();
00277   virtual void EnlargeOutputRequestedRegion(DataObject *output);
00278 
00283   itkGetConstReferenceMacro( LargeValue, PixelType );
00284 
00285   OutputRegionType                              m_BufferedRegion;
00286   typedef typename LevelSetImageType::IndexType LevelSetIndexType;
00287   LevelSetIndexType                             m_StartIndex;
00288   LevelSetIndexType                             m_LastIndex;
00289 
00290   itkGetConstReferenceMacro( StartIndex, LevelSetIndexType );
00291   itkGetConstReferenceMacro( LastIndex, LevelSetIndexType );
00292 
00293 private:
00294   FastMarchingImageFilter(const Self&); //purposely not implemented
00295   void operator=(const Self&); //purposely not implemented
00296   
00297   NodeContainerPointer                          m_AlivePoints;
00298   NodeContainerPointer                          m_TrialPoints;
00299 
00300   LabelImagePointer                             m_LabelImage;
00301   
00302   double                                        m_SpeedConstant;
00303   double                                        m_InverseSpeed;
00304   double                                        m_StoppingValue;
00305     
00306   bool                                          m_CollectPoints;
00307   NodeContainerPointer                          m_ProcessedPoints;
00308 
00309   OutputRegionType                              m_OutputRegion;
00310   OutputSpacingType                             m_OutputSpacing;
00311   OutputPointType                               m_OutputOrigin;
00312   bool                                          m_OverrideOutputInformation;
00313 
00314 
00315   typename LevelSetImageType::PixelType         m_LargeValue;
00316   AxisNodeType                                  m_NodesUsed[SetDimension];
00317 
00321   typedef std::vector<AxisNodeType> HeapContainer;
00322   typedef std::greater<AxisNodeType> NodeComparer;
00323   typedef std::priority_queue< AxisNodeType, HeapContainer, NodeComparer > HeapType;
00324 
00325   HeapType    m_TrialHeap;
00326 
00327   double    m_NormalizationFactor;
00328 };
00329 
00330 } // namespace itk
00331 
00332 
00333 #ifndef ITK_MANUAL_INSTANTIATION
00334 #include "itkFastMarchingImageFilter.txx"
00335 #endif
00336 
00337 #endif

Generated at Wed May 24 23:06:16 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000