]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Image/DijkstraWithEndPointDetection.h
c63f4f11ecf6073d3ae7fd9bba319ce7156a9ec8
[FrontAlgorithms.git] / lib / fpa / Image / DijkstraWithEndPointDetection.h
1 #ifndef __FPA__IMAGE__DIJKSTRAWITHENDPOINTDETECTION__H__
2 #define __FPA__IMAGE__DIJKSTRAWITHENDPOINTDETECTION__H__
3
4 #include <map>
5 #include <itkImage.h>
6 #include <fpa/Image/Dijkstra.h>
7
8 namespace fpa
9 {
10   namespace Image
11   {
12     /**
13      * @param I Input image type
14      * @param O Output image type
15      */
16     template< class I, class O >
17     class DijkstraWithEndPointDetection
18       : public Dijkstra< I, O >
19     {
20     public:
21       typedef DijkstraWithEndPointDetection   Self;
22       typedef Dijkstra< I, O >                Superclass;
23       typedef itk::SmartPointer< Self >       Pointer;
24       typedef itk::SmartPointer< const Self > ConstPointer;
25
26       typedef typename Superclass::TInputImage         TInputImage;
27       typedef typename Superclass::TOutputImage        TOutputImage;
28       typedef typename Superclass::TVertex             TVertex;
29       typedef typename Superclass::TVertexCompare      TVertexCompare;
30       typedef typename Superclass::TValue              TValue;
31       typedef typename Superclass::TResult             TResult;
32       typedef typename Superclass::TCostFunction       TCostFunction;
33       typedef typename Superclass::TConversionFunction TConversionFunction;
34       typedef typename Superclass::_TVertices          TVertices;
35
36       typedef typename Superclass::TStartEvent     TStartEvent;
37       typedef typename Superclass::TStartLoopEvent TStartLoopEvent;
38       typedef typename Superclass::TEndEvent       TEndEvent;
39       typedef typename Superclass::TEndLoopEvent   TEndLoopEvent;
40       typedef typename Superclass::TAliveEvent     TAliveEvent;
41       typedef typename Superclass::TFrontEvent     TFrontEvent;
42       typedef typename Superclass::TFreezeEvent    TFreezeEvent;
43
44       typedef typename
45       Superclass::TStartBacktrackingEvent TStartBacktrackingEvent;
46       typedef typename
47       Superclass::TEndBacktrackingEvent TEndBacktrackingEvent;
48       typedef typename
49       Superclass::TBacktrackingEvent TBacktrackingEvent;
50
51       typedef unsigned short                          TLabel;
52       typedef itk::Image< TLabel, I::ImageDimension > TLabelImage;
53
54       typedef std::set< TVertex, TVertexCompare > TUniqueVertices;
55       typedef std::map< TVertex, TLabel, TVertexCompare >  TBranch;
56       typedef std::map< TVertex, TBranch, TVertexCompare > TBranches;
57
58     protected:
59       typedef typename Superclass::_TVertices      _TVertices;
60       typedef typename Superclass::_TCollision     _TCollision;
61       typedef typename Superclass::_TCollisionsRow _TCollisionsRow;
62       typedef typename Superclass::_TCollisions    _TCollisions;
63       typedef typename Superclass::_TNode          _TNode;
64       typedef typename Superclass::_TNodes         _TNodes;
65
66       typedef typename I::PixelType  _TPixel;
67       typedef typename I::RegionType _TRegion;
68       typedef typename I::SizeType   _TSize;
69
70       typedef std::pair< TResult, TVertex >     _TCandidate;
71       typedef std::multimap< TResult, TVertex > _TCandidates;
72
73     public:
74       itkNewMacro( Self );
75       itkTypeMacro( DijkstraWithEndPointDetection, Dijkstra );
76
77       itkGetConstMacro( EndPoints, TUniqueVertices );
78       itkGetConstMacro( BifurcationPoints, TUniqueVertices );
79       itkGetConstMacro( NumberOfBranches, unsigned long );
80       itkGetConstMacro( Branches, TBranches );
81
82     public:
83       TLabelImage* GetLabelImage( );
84       const TLabelImage* GetLabelImage( ) const;
85       void GraftLabelImage( itk::DataObject* obj );
86
87     protected:
88       DijkstraWithEndPointDetection( );
89       virtual ~DijkstraWithEndPointDetection( );
90
91       virtual void _BeforeGenerateData( );
92       virtual void _AfterGenerateData( );
93       virtual void _SetResult( const TVertex& v, const _TNode& n );
94
95       _TRegion _Region( const TVertex& c, const double& r );
96
97       template< class _T >
98       TVertex _MaxInRegion(
99         const _T* image, const TVertex& v, const double& r
100         );
101
102       void _Label( const TVertex& v, const TLabel& l );
103
104     private:
105       // Purposely not implemented
106       DijkstraWithEndPointDetection( const Self& other );
107       Self& operator=( const Self& other );
108
109     protected:
110       unsigned int m_LabelImageIndex;
111
112       _TCandidates    m_Candidates;
113       TUniqueVertices m_BifurcationPoints;
114       TUniqueVertices m_EndPoints;
115       unsigned long   m_NumberOfBranches;
116       TBranches       m_Branches;
117     };
118
119   } // ecapseman
120
121 } // ecapseman
122
123 #include <fpa/Image/DijkstraWithEndPointDetection.hxx>
124
125 #endif // __FPA__IMAGE__DIJKSTRAWITHENDPOINTDETECTION__H__
126
127 // eof - $RCSfile$