]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Common/OriginalRandomWalker.h
...
[FrontAlgorithms.git] / lib / fpa / Common / OriginalRandomWalker.h
1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5 #ifndef __fpa__Common__OriginalRandomWalker__h__
6 #define __fpa__Common__OriginalRandomWalker__h__
7
8 #include <fpa/Config.h>
9 #include <vector>
10 #include <itkImage.h>
11 #include <itkImageToImageFilter.h>
12
13 namespace fpa
14 {
15   namespace Common
16   {
17     /**
18      */
19     template< class _TImage, class _TLabels, class _TScalar = float >
20     class OriginalRandomWalker
21       : public itk::ImageToImageFilter< _TImage, _TLabels >
22     {
23     public:
24       typedef _TImage  TImage;
25       typedef _TLabels TLabels;
26       typedef _TScalar TScalar;
27
28       typedef OriginalRandomWalker                       Self;
29       typedef itk::ImageToImageFilter< TImage, TLabels > Superclass;
30       typedef itk::SmartPointer< Self >                  Pointer;
31       typedef itk::SmartPointer< const Self >            ConstPointer;
32
33       typedef itk::Image< TScalar, TImage::ImageDimension > TScalarImage;
34       typedef typename TImage::IndexType  TIndex;
35       typedef typename TImage::PixelType  TPixel;
36       typedef typename TImage::RegionType TRegion;
37       typedef typename TLabels::PixelType TLabel;
38
39     public:
40       itkNewMacro( Self );
41       itkTypeMacro(
42         fpa::Common::OriginalRandomWalker, itk::ImageToImageFilter
43         );
44
45       itkGetConstMacro( Beta, TScalar );
46       itkSetMacro( Beta, TScalar );
47
48       itkGetConstMacro( Epsilon, TScalar );
49       itkSetMacro( Epsilon, TScalar );
50
51       itkBooleanMacro( NormalizeWeights );
52       itkGetConstMacro( NormalizeWeights, bool );
53       itkSetMacro( NormalizeWeights, bool );
54
55       fpaFilterInputMacro( InputLabels, TLabels );
56       fpaFilterOutputMacro( OutputProbabilities, TScalarImage );
57
58     public:
59       void AddSeed( const TIndex& seed, const TLabel& label );
60
61     protected:
62       OriginalRandomWalker( );
63       virtual ~OriginalRandomWalker( );
64
65       virtual void GenerateData( ) override;
66
67       static unsigned long _1D( const TIndex& idx, const TRegion& region );
68       static TIndex _ND( const unsigned long& i, const TRegion& region );
69
70     private:
71       // Purposely not implemented
72       OriginalRandomWalker( const Self& other );
73       Self& operator=( const Self& other );
74
75     protected:
76       std::vector< TIndex > m_Seeds;
77       std::vector< TLabel > m_Labels;
78
79       TScalar m_Beta;
80       TScalar m_Epsilon;
81       bool m_NormalizeWeights;
82     };
83
84   } // ecapseman
85
86 } // ecapseman
87
88 #ifndef ITK_MANUAL_INSTANTIATION
89 #  include <fpa/Common/OriginalRandomWalker.hxx>
90 #endif // ITK_MANUAL_INSTANTIATION
91 #endif // __fpa__Common__OriginalRandomWalker__h__
92 // eof - $RCSfile$