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