]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Image/Algorithm.h
Refactoring: gaussian model estimator
[FrontAlgorithms.git] / lib / fpa / Image / Algorithm.h
1 #ifndef __FPA__IMAGE__ALGORITHM__H__
2 #define __FPA__IMAGE__ALGORITHM__H__
3
4 #include <itkImage.h>
5 #include <fpa/Image/MinimumSpanningTree.h>
6
7 namespace fpa
8 {
9   namespace Image
10   {
11     /**
12      * A generic front propagation algorithm were vertices are image pixels.
13      *
14      * @param I Input image type
15      * @param O Output image type
16      * @param A Base algorithm (RegionGrow, Dijkstra or FastMarching)
17      */
18     template< class I, class O, class A >
19     class Algorithm
20       : public A
21     {
22     public:
23       /// Standard class typdedefs
24       typedef Algorithm                       Self;
25       typedef A                               Superclass;
26       typedef itk::SmartPointer< Self >       Pointer;
27       typedef itk::SmartPointer< const Self > ConstPointer;
28
29       /// Template input values
30       typedef I TInputImage;
31       typedef O TOutputImage;
32
33       typedef typename Superclass::TVertex TVertex;
34       typedef typename Superclass::TValue  TValue;
35       typedef typename Superclass::TResult TResult;
36
37     protected:
38       typedef typename Superclass::_TVertices      _TVertices;
39       typedef typename Superclass::_TCollision     _TCollision;
40       typedef typename Superclass::_TCollisionsRow _TCollisionsRow;
41       typedef typename Superclass::_TCollisions    _TCollisions;
42       typedef typename Superclass::_TNode          _TNode;
43       typedef typename Superclass::_TNodes         _TNodes;
44
45       typedef fpa::Image::MinimumSpanningTree< TVertex, _TNode, _TCollisions, I::ImageDimension, Self::AliveLabel > _TMarks;
46
47     public:
48       typedef _TMarks TMinimumSpanningTree;
49
50     public:
51       itkTypeMacro( Algorithm, TAlgorithm );
52
53       /// Set/Get
54       itkGetConstMacro( NeighborhoodOrder, unsigned int );
55       itkSetMacro( NeighborhoodOrder, unsigned int );
56
57     public:
58       TMinimumSpanningTree* GetMinimumSpanningTree( );
59       const TMinimumSpanningTree* GetMinimumSpanningTree( ) const;
60       void GraftMinimumSpanningTree( itk::DataObject* obj );
61
62     protected:
63       Algorithm( );
64       virtual ~Algorithm( );
65
66       virtual void _BeforeGenerateData( );
67       virtual void _AfterGenerateData( );
68
69       // Graph-related abstract methods
70       virtual unsigned long _NumberOfVertices( ) const;
71       virtual const TValue& _VertexValue( const TVertex& v ) const;
72       virtual double _Distance(
73         const TVertex& a, const TVertex& b
74         ) const;
75       virtual bool _HasEdge( const TVertex& a, const TVertex& b ) const;
76       virtual void _Neighborhood(
77         _TVertices& neighborhood, const TVertex& v
78         ) const;
79
80       // Results-related abstract methods
81       virtual void _InitResults( );
82       virtual const TResult& _Result( const TVertex& v ) const;
83       virtual void _SetResult( const TVertex& v, const TResult& r );
84
85       // Marks-related abstract methods
86       virtual const _TNode& _Node( const TVertex& v ) const;
87       virtual void _InitMarks( );
88       virtual void _Mark( const _TNode& node );
89
90     private:
91       // Purposely not implemented
92       Algorithm( const Self& other );
93       Self& operator=( const Self& other );
94
95     protected:
96       unsigned int m_NeighborhoodOrder;
97     };
98
99   } // ecapseman
100
101 } // ecapseman
102
103 #include <fpa/Image/Algorithm.hxx>
104
105 #endif // __FPA__IMAGE__ALGORITHM__H__
106
107 // eof - $RCSfile$