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: 2008-01-18 20:07:31 $
00007   Version:   $Revision: 1.37 $
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 
00101 template <
00102   class TLevelSet, 
00103   class TSpeedImage = Image<float,::itk::GetImageDimension<TLevelSet>::ImageDimension> >
00104 class ITK_EXPORT FastMarchingImageFilter :
00105     public ImageToImageFilter<TSpeedImage,TLevelSet>
00106 {
00107 public:
00109   typedef FastMarchingImageFilter Self;
00110   typedef ImageSource<TLevelSet> Superclass;
00111   typedef SmartPointer<Self> Pointer;
00112   typedef SmartPointer<const Self>  ConstPointer;
00113 
00115   itkNewMacro(Self);
00116 
00118   itkTypeMacro(FastMarchingImageFilter, ImageSource);
00119 
00121   typedef LevelSetTypeDefault<TLevelSet>              LevelSetType;
00122   typedef typename LevelSetType::LevelSetImageType    LevelSetImageType;
00123   typedef typename LevelSetType::LevelSetPointer      LevelSetPointer;
00124   typedef typename LevelSetType::PixelType            PixelType;
00125   typedef typename LevelSetType::NodeType             NodeType;
00126   typedef typename LevelSetType::NodeContainer        NodeContainer;
00127   typedef typename LevelSetType::NodeContainerPointer NodeContainerPointer;
00128   typedef typename LevelSetImageType::SizeType        OutputSizeType;
00129   typedef typename LevelSetImageType::RegionType      OutputRegionType;
00130   typedef typename LevelSetImageType::SpacingType     OutputSpacingType;
00131   typedef typename LevelSetImageType::PointType       OutputPointType;
00132 
00133   class AxisNodeType : public NodeType
00134   {
00135   public:
00136     int GetAxis() const { return m_Axis; }
00137     void SetAxis( int axis ) { m_Axis = axis; }
00138     const AxisNodeType & operator=(const NodeType & node)
00139                           { this->NodeType::operator=(node); return *this; }
00140   private:
00141     int m_Axis;
00142   };
00143 
00145   typedef TSpeedImage SpeedImageType;
00146 
00148   typedef typename SpeedImageType::Pointer        SpeedImagePointer;
00149   typedef typename SpeedImageType::ConstPointer   SpeedImageConstPointer;
00150 
00152   itkStaticConstMacro(SetDimension, unsigned int,
00153                       LevelSetType::SetDimension);
00154   itkStaticConstMacro(SpeedImageDimension, unsigned int,
00155                       SpeedImageType::ImageDimension);
00157 
00159   typedef Index<itkGetStaticConstMacro(SetDimension)> IndexType;
00160 
00165   enum LabelType { FarPoint, AlivePoint, TrialPoint };
00166 
00168   typedef Image<unsigned char, itkGetStaticConstMacro(SetDimension)> LabelImageType;
00169 
00171   typedef typename LabelImageType::Pointer LabelImagePointer;
00172 
00175   void SetAlivePoints( NodeContainer * points )
00176   { 
00177     m_AlivePoints = points; 
00178     this->Modified(); 
00179   };
00181 
00183   NodeContainerPointer GetAlivePoints( )
00184   { return m_AlivePoints; };
00185 
00188   void SetTrialPoints( NodeContainer * points )
00189   { 
00190     m_TrialPoints = points;
00191     this->Modified();
00192   };
00194 
00196   NodeContainerPointer GetTrialPoints( )
00197   { return m_TrialPoints; };
00198 
00200   LabelImagePointer GetLabelImage() const
00201   { return m_LabelImage; };
00202 
00206   void SetSpeedConstant( double value )
00207   {
00208     m_SpeedConstant = value;
00209     m_InverseSpeed = -1.0 * vnl_math_sqr( 1.0 / m_SpeedConstant );
00210     this->Modified();
00211   }
00213 
00215   itkGetConstReferenceMacro( SpeedConstant, double );
00216 
00221   itkSetMacro( NormalizationFactor, double );
00222   itkGetMacro( NormalizationFactor, double );
00224 
00228   itkSetMacro( StoppingValue, double );
00229 
00231   itkGetConstReferenceMacro( StoppingValue, double );
00232 
00237   itkSetMacro( CollectPoints, bool );
00238 
00240   itkGetConstReferenceMacro( CollectPoints, bool );
00241   itkBooleanMacro( CollectPoints );
00243 
00248   NodeContainerPointer GetProcessedPoints() const
00249   { return m_ProcessedPoints; }
00250 
00251 
00258   virtual void SetOutputSize( const OutputSizeType& size )
00259   { m_OutputRegion = size; }
00260   virtual OutputSizeType GetOutputSize() const
00261   { return m_OutputRegion.GetSize(); }
00262   itkSetMacro( OutputRegion, OutputRegionType );
00263   itkGetConstReferenceMacro( OutputRegion, OutputRegionType );
00264   itkSetMacro( OutputSpacing, OutputSpacingType );
00265   itkGetConstReferenceMacro( OutputSpacing, OutputSpacingType );
00266   itkSetMacro( OutputOrigin, OutputPointType );
00267   itkGetConstReferenceMacro( OutputOrigin, OutputPointType );
00268   itkSetMacro( OverrideOutputInformation, bool );
00269   itkGetConstReferenceMacro( OverrideOutputInformation, bool );
00270   itkBooleanMacro( OverrideOutputInformation );
00272 
00273 #ifdef ITK_USE_CONCEPT_CHECKING
00274 
00275   itkConceptMacro(SameDimensionCheck,
00276     (Concept::SameDimension<SetDimension, SpeedImageDimension>));
00277   itkConceptMacro(SpeedConvertibleToDoubleCheck,
00278     (Concept::Convertible<typename TSpeedImage::PixelType, double>));
00279   itkConceptMacro(DoubleConvertibleToLevelSetCheck,
00280     (Concept::Convertible<double, PixelType>));
00281   itkConceptMacro(LevelSetOStreamWritableCheck,
00282     (Concept::OStreamWritable<PixelType>));
00283 
00285 #endif
00286 
00287 protected:
00288   FastMarchingImageFilter();
00289   ~FastMarchingImageFilter(){};
00290   void PrintSelf( std::ostream& os, Indent indent ) const;
00291 
00292   virtual void Initialize( LevelSetImageType * );
00293   virtual void UpdateNeighbors( const IndexType& index, 
00294                                 const SpeedImageType *, LevelSetImageType * );
00295   virtual double UpdateValue( const IndexType& index, 
00296                               const SpeedImageType *, LevelSetImageType * );
00297 
00298 
00299   const AxisNodeType& GetNodeUsedInCalculation(unsigned int idx) const
00300   { return m_NodesUsed[idx]; }
00301 
00302   void GenerateData();
00303 
00305   virtual void GenerateOutputInformation();
00306   virtual void EnlargeOutputRequestedRegion(DataObject *output);
00308 
00313   itkGetConstReferenceMacro( LargeValue, PixelType );
00314 
00315   OutputRegionType                              m_BufferedRegion;
00316   typedef typename LevelSetImageType::IndexType LevelSetIndexType;
00317   LevelSetIndexType                             m_StartIndex;
00318   LevelSetIndexType                             m_LastIndex;
00319 
00320   itkGetConstReferenceMacro( StartIndex, LevelSetIndexType );
00321   itkGetConstReferenceMacro( LastIndex, LevelSetIndexType );
00322 
00323 private:
00324   FastMarchingImageFilter(const Self&); //purposely not implemented
00325   void operator=(const Self&); //purposely not implemented
00326   
00327   NodeContainerPointer                          m_AlivePoints;
00328   NodeContainerPointer                          m_TrialPoints;
00329 
00330   LabelImagePointer                             m_LabelImage;
00331   
00332   double                                        m_SpeedConstant;
00333   double                                        m_InverseSpeed;
00334   double                                        m_StoppingValue;
00335     
00336   bool                                          m_CollectPoints;
00337   NodeContainerPointer                          m_ProcessedPoints;
00338 
00339   OutputRegionType                              m_OutputRegion;
00340   OutputSpacingType                             m_OutputSpacing;
00341   OutputPointType                               m_OutputOrigin;
00342   bool                                          m_OverrideOutputInformation;
00343 
00344 
00345   typename LevelSetImageType::PixelType         m_LargeValue;
00346   AxisNodeType                                  m_NodesUsed[SetDimension];
00347 
00351   typedef std::vector<AxisNodeType> HeapContainer;
00352   typedef std::greater<AxisNodeType> NodeComparer;
00353   typedef std::priority_queue< AxisNodeType, HeapContainer, NodeComparer > HeapType;
00354 
00355   HeapType    m_TrialHeap;
00356 
00357   double    m_NormalizationFactor;
00358 };
00359 
00360 } // namespace itk
00361 
00362 
00363 #ifndef ITK_MANUAL_INSTANTIATION
00364 #include "itkFastMarchingImageFilter.txx"
00365 #endif
00366 
00367 #endif
00368 

Generated at Mon Apr 14 12:18:41 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000