]> Creatis software - FrontAlgorithms.git/blob - appli/CTBronchi/Process.h
...
[FrontAlgorithms.git] / appli / CTBronchi / Process.h
1 // =========================================================================
2 // @author Leonardo Florez Valencia (florez-l@javeriana.edu.co)
3 // =========================================================================
4 #ifndef __CTBronchi__Process__h__
5 #define __CTBronchi__Process__h__
6
7 #include <map>
8 #include <set>
9 #include <tuple>
10 #include <fpa_ctbronchi_export.h>
11 #include "Image.h"
12 #include "Skeleton.h"
13
14 namespace CTBronchi
15 {
16   class FPA_CTBRONCHI_EXPORT Process
17   {
18   public:
19     typedef Process Self;
20
21     // Some types and values
22     static const unsigned int Dim = 3;
23     typedef short         TPixel;
24     typedef unsigned char TLabel;
25     typedef float         TScalar;
26     typedef std::string   TString;
27
28     // Arguments
29     typedef std::tuple< TString, TString, bool > TStrArg;
30     typedef std::tuple< TScalar, TString, bool > TDblArg;
31     typedef std::map< TString, TStrArg >         TStrArgs;
32     typedef std::map< TString, TDblArg >         TDblArgs;
33
34     // Images
35     typedef CTBronchi::Image< TPixel, Dim >  TPixelImage;
36     typedef CTBronchi::Image< TLabel, Dim >  TLabelImage;
37     typedef CTBronchi::Image< TScalar, Dim > TScalarImage;
38
39     // Skeleton
40     typedef CTBronchi::Skeleton< Dim > TSkeleton;
41
42     // Seed
43     typedef TPixelImage::TImage::PointType    TPoint;
44     typedef TPixelImage::TImage::IndexType    TIndex;
45     typedef std::pair< TIndex, TPoint >       TSeed;
46     typedef std::pair< TIndex, unsigned int > TEndPoint;
47     struct TEndPointCompare
48     {
49       bool operator()( const TEndPoint& a, const TEndPoint& b ) const
50         {
51           return( cmp( a.first, b.first ) );
52         }
53       TIndex::LexicographicCompare cmp;
54     };
55     typedef std::set< TEndPoint, TEndPointCompare > TEndPoints;
56
57   public:
58     Process( );
59     virtual ~Process( );
60
61     void ParseArguments( int argc, char* argv[] );
62     void Update( );
63
64   protected:
65     template< class _TImage >
66     void _Input( _TImage& input );
67
68     template< class _TInput, class _TVesselness >
69     void _Vesselness( _TInput& input, _TVesselness& vesselness );
70
71     template< class _TInput, class _TMori, class _TSeed >
72     void _Mori( _TInput& input, _TMori& mori, _TSeed& seed );
73
74     template< class _TInput, class _TMori, class _TVesselness, class _TLabels >
75     void _MoriLabelling(
76       _TInput& input, _TMori& mori, _TVesselness& vesselness, _TLabels& labels
77       );
78
79     template< class _TInput, class _TLabels, class _TFastRW >
80     void _FastRW( _TInput& input, _TLabels& labels, _TFastRW& fastrw );
81
82     template< class _TInput, class _TLabels, class _TVesselness, class _TSliceRW >
83     void _SliceRW(
84       _TInput& input, _TLabels& labels, _TVesselness& vesselness, _TSliceRW& slicerw
85       );
86
87     template< class _TInput >
88     void _AndImages( _TInput& a, _TInput& b, _TInput& c );
89
90     template< class _TInput, class _TSkeleton, class _TIndices >
91     void _Skeleton(
92       _TInput& a, _TSkeleton& s,
93       _TIndices& e, unsigned int id,
94       const TString& fname
95       );
96
97     template< class _TIndices >
98     void _Points(
99       _TIndices& a, unsigned int ca,
100       _TIndices& b, unsigned int cb,
101       _TIndices& c, unsigned int cc,
102       _TIndices& d
103       );
104
105   protected:
106     TStrArgs m_StrArgs;
107     TDblArgs m_DblArgs;
108
109     TSeed  m_Seed;
110     TLabel m_UndefinedLabel;
111     TLabel m_InsideLabel;
112     TLabel m_OutsideLabel;
113
114     TPixelImage  m_Input;
115     TScalarImage m_Vesselness;
116     TLabelImage  m_Mori;
117     TLabelImage  m_Labels;
118     TLabelImage  m_FastRW;
119     TLabelImage  m_SliceRW;
120     TLabelImage  m_AndRW;
121
122     TSkeleton m_FastRWSkeleton;
123     TSkeleton m_SliceRWSkeleton;
124     TSkeleton m_AndRWSkeleton;
125
126     TEndPoints m_FastRWPoints;
127     TEndPoints m_SliceRWPoints;
128     TEndPoints m_AndRWPoints;
129   };
130
131 } // ecapseman
132
133 #endif // __CTBronchi__Process__h__
134
135 // eof - $RCSfile$