]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Image/DijkstraWithEndPointDetection.h
...
[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::TSpace               TSpace;
35       typedef typename Superclass::TMinimumSpanningTree TMinimumSpanningTree;
36       typedef typename Superclass::TCostFunction        TCostFunction;
37       typedef typename Superclass::TConversionFunction  TConversionFunction;
38       typedef typename Superclass::_TVertices           TVertices;
39
40       typedef typename Superclass::TStartEvent     TStartEvent;
41       typedef typename Superclass::TStartLoopEvent TStartLoopEvent;
42       typedef typename Superclass::TEndEvent       TEndEvent;
43       typedef typename Superclass::TEndLoopEvent   TEndLoopEvent;
44       typedef typename Superclass::TAliveEvent     TAliveEvent;
45       typedef typename Superclass::TFrontEvent     TFrontEvent;
46       typedef typename Superclass::TFreezeEvent    TFreezeEvent;
47
48       typedef typename
49       Superclass::TStartBacktrackingEvent TStartBacktrackingEvent;
50       typedef typename
51       Superclass::TEndBacktrackingEvent TEndBacktrackingEvent;
52       typedef typename
53       Superclass::TBacktrackingEvent TBacktrackingEvent;
54
55       typedef unsigned short                          TLabel;
56       typedef itk::Image< TLabel, I::ImageDimension > TLabelImage;
57
58       typedef fpa::Base::
59       UniqueValuesContainer< TVertex, TVertexCompare > TUniqueVertices;
60       typedef fpa::Base::
61       MatrixValuesContainer< TVertex, TLabel, TVertexCompare > TBranches;
62
63     protected:
64       typedef typename Superclass::_TVertices      _TVertices;
65       typedef typename Superclass::_TCollision     _TCollision;
66       typedef typename Superclass::_TCollisionsRow _TCollisionsRow;
67       typedef typename Superclass::_TCollisions    _TCollisions;
68       typedef typename Superclass::_TNode          _TNode;
69       typedef typename Superclass::_TNodes         _TNodes;
70
71       typedef typename I::PixelType  _TPixel;
72       typedef typename I::RegionType _TRegion;
73       typedef typename I::SizeType   _TSize;
74
75       typedef std::pair< TResult, TVertex >     _TCandidate;
76       typedef std::multimap< TResult, TVertex > _TCandidates;
77
78     public:
79       itkNewMacro( Self );
80       itkTypeMacro( DijkstraWithEndPointDetection, Dijkstra );
81
82       itkBooleanMacro( CorrectSeeds );
83       itkBooleanMacro( CorrectEndPoints );
84
85       itkGetConstMacro( CorrectSeeds, bool );
86       itkGetConstMacro( CorrectEndPoints, bool );
87       itkGetConstMacro( SafetyNeighborhoodSize, unsigned int );
88
89       itkGetConstMacro( NumberOfBranches, unsigned long );
90
91       itkSetMacro( CorrectSeeds, bool );
92       itkSetMacro( CorrectEndPoints, bool );
93       itkSetMacro( SafetyNeighborhoodSize, unsigned int );
94
95     public:
96       TLabelImage* GetLabelImage( );
97       const TLabelImage* GetLabelImage( ) const;
98       void GraftLabelImage( itk::DataObject* obj );
99
100       TUniqueVertices* GetEndPoints( );
101       const TUniqueVertices* GetEndPoints( ) const;
102       void GraftEndPoints( itk::DataObject* obj );
103
104       TUniqueVertices* GetBifurcations( );
105       const TUniqueVertices* GetBifurcations( ) const;
106       void GraftBifurcations( itk::DataObject* obj );
107
108       TBranches* GetBranches( );
109       const TBranches* GetBranches( ) const;
110       void GraftBranches( itk::DataObject* obj );
111
112     protected:
113       DijkstraWithEndPointDetection( );
114       virtual ~DijkstraWithEndPointDetection( );
115
116       virtual void _BeforeGenerateData( );
117       virtual void _AfterGenerateData( );
118       virtual void _SetResult( const TVertex& v, const _TNode& n );
119
120       void _EndPointsAndBifurcations( );
121       void _FindBranches( );
122       void _LabelAll( );
123
124       _TRegion _Region( const TVertex& c, const double& r );
125
126       template< class _T >
127       TVertex _MaxInRegion(
128         const _T* image, const TVertex& v, const double& r
129         );
130
131     private:
132       // Purposely not implemented
133       DijkstraWithEndPointDetection( const Self& other );
134       Self& operator=( const Self& other );
135
136     protected:
137       unsigned int m_LabelImageIndex;
138       unsigned int m_BifurcationsIndex;
139       unsigned int m_EndPointsIndex;
140       unsigned int m_BranchesIndex;
141
142       bool m_CorrectSeeds;
143       bool m_CorrectEndPoints;
144       unsigned int m_SafetyNeighborhoodSize;
145
146       _TCandidates  m_Candidates;
147       unsigned long m_NumberOfBranches;
148     };
149
150   } // ecapseman
151
152 } // ecapseman
153
154 #ifndef ITK_MANUAL_INSTANTIATION
155 #include <fpa/Image/DijkstraWithEndPointDetection.hxx>
156 #endif // ITK_MANUAL_INSTANTIATION
157
158 #endif // __FPA__IMAGE__DIJKSTRAWITHENDPOINTDETECTION__H__
159
160 // eof - $RCSfile$