]> Creatis software - FrontAlgorithms.git/blob - appli/CTArteries/algorithms/RandomWalkSegmentation.h
...
[FrontAlgorithms.git] / appli / CTArteries / algorithms / RandomWalkSegmentation.h
1 // =========================================================================
2 // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
3 // =========================================================================
4 #ifndef __RandomWalkSegmentation__h__
5 #define __RandomWalkSegmentation__h__
6
7 #include <itkImageToImageFilter.h>
8 #include <fpa/Config.h>
9 #include <fpa/DataStructures/Image/Path.h>
10
11 /**
12  */
13 template< class _TInputImage, class _TOutputImage >
14 class RandomWalkSegmentation
15   : public itk::ImageToImageFilter< _TInputImage, _TOutputImage >
16 {
17 public:
18   typedef _TInputImage  TInputImage;
19   typedef _TOutputImage TOutputImage;
20
21   typedef itk::ImageToImageFilter< TInputImage, TOutputImage > Superclass;
22   typedef RandomWalkSegmentation        Self;
23   typedef itk::SmartPointer< Self >       Pointer;
24   typedef itk::SmartPointer< const Self > ConstPointer;
25
26   typedef typename TInputImage::IndexType TIndex;
27   typedef typename TInputImage::PointType TPoint;
28
29   struct TSeed
30   {
31     TIndex Index;
32     TPoint Point;
33     bool IsPoint;
34   };
35   typedef fpa::DataStructures::Image::Path< TInputImage::ImageDimension > TPath;
36
37 public:
38   itkNewMacro( Self );
39   itkTypeMacro( RandomWalkSegmentation, itk::ImageToImageFilter );
40
41   itkGetConstMacro( StartSeed, TSeed );
42   itkGetConstMacro( EndSeed, TSeed );
43
44   itkGetConstMacro( Beta, double );
45   itkSetMacro( Beta, double );
46
47   itkGetConstMacro( Sigma, double );
48   itkSetMacro( Sigma, double );
49
50   itkGetConstMacro( Radius, double );
51   itkSetMacro( Radius, double );
52
53   fpaFilterOutputMacro( OutputAxis, TPath );
54
55 public:
56   void AddSeed( const TIndex& s );
57   void AddSeed( const TPoint& s );
58   void ClearSeeds( );
59   unsigned long GetNumberOfSeeds( ) const;
60
61   void SetStartSeed( const TIndex& s );
62   void SetStartSeed( const TPoint& s );
63
64   void SetEndSeed( const TIndex& s );
65   void SetEndSeed( const TPoint& s );
66
67 protected:
68   RandomWalkSegmentation( );
69   virtual ~RandomWalkSegmentation( );
70
71   virtual void GenerateData( ) override;
72
73 private:
74   template< class _TImage >
75   void _save( _TImage* image, const std::string& fname );
76
77 private:
78   // Purposely not implemented
79   RandomWalkSegmentation( const Self& other );
80   Self& operator=( const Self& other );
81
82 protected:
83   TSeed m_StartSeed;
84   TSeed m_EndSeed;
85   std::vector< TSeed > m_Seeds;
86
87   double m_Beta;
88   double m_Sigma;
89   double m_Radius;
90 };
91
92 #ifndef ITK_MANUAL_INSTANTIATION
93 #  include "RandomWalkSegmentation.hxx"
94 #endif // ITK_MANUAL_INSTANTIATION
95
96 #endif // __RandomWalkSegmentation__h__
97
98 // eof - $RCSfile$