]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Base/Mori.h
...
[FrontAlgorithms.git] / lib / fpa / Base / Mori.h
1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5
6 #ifndef __fpa__Base__Mori__h__
7 #define __fpa__Base__Mori__h__
8
9 #include <deque>
10 #include <set>
11 #include <itkConceptChecking.h>
12 #include <itkFunctionBase.h>
13
14 #include <ivq/ITK/PeakDetector.h>
15 #include <fpa/Base/Functors/RegionGrow/BinaryThreshold.h>
16
17 namespace fpa
18 {
19   namespace Base
20   {
21     /**
22      */
23     template< class _TAlgorithm >
24     class Mori
25       : public _TAlgorithm
26     {
27     public:
28       typedef Mori                            Self;
29       typedef _TAlgorithm                     Superclass;
30       typedef itk::SmartPointer< Self >       Pointer;
31       typedef itk::SmartPointer< const Self > ConstPointer;
32
33       typedef typename _TAlgorithm::TNode        TNode;
34       typedef typename _TAlgorithm::TNodes       TNodes;
35       typedef typename _TAlgorithm::TInputValue  TInputValue;
36       typedef typename _TAlgorithm::TOutputValue TOutputValue;
37       typedef typename _TAlgorithm::TFrontId     TFrontId;
38       typedef typename _TAlgorithm::TVertex      TVertex;
39
40       typedef std::deque< TNode >     TQueue;
41       typedef std::set< TInputValue > TThresholds;
42
43       typedef ivq::ITK::PeakDetector TPeakDetector;
44       typedef TPeakDetector::TPeak   TPeak;
45
46       typedef fpa::Base::Functors::RegionGrow::BinaryThreshold< TInputValue > TPredicate;
47
48     public:
49       itkConceptMacro(
50         Check_TOutputValue,
51         ( itk::Concept::IsUnsignedInteger< TOutputValue > )
52         );
53
54       itkGetConstMacro( InsideValue, TOutputValue );
55       itkSetMacro( InsideValue, TOutputValue );
56
57       itkGetConstMacro( MinimumThreshold, TInputValue );
58       itkSetMacro( MinimumThreshold, TInputValue );
59
60     public:
61       virtual itk::ModifiedTimeType GetMTime( ) const override;
62
63       TOutputValue GetOutsideValue( ) const;
64       void SetOutsideValue( const TOutputValue& v );
65
66       unsigned long GetSignalKernelSize( ) const;
67       double GetSignalThreshold( ) const;
68       double GetSignalInfluence( ) const;
69
70       void SetSignalKernelSize( unsigned long k );
71       void SetSignalThreshold( double t );
72       void SetSignalInfluence( double i );
73
74       void ClearThresholds( );
75       void AddThreshold( const TInputValue& thr );
76       void SetThresholds(
77         const TInputValue& init,
78         const TInputValue& end,
79         const TInputValue& delta
80         );
81       const TThresholds& GetThresholds( ) const;
82       unsigned long GetNumberOfEvaluatedThresholds( ) const;
83       TInputValue GetOptimumThreshold( ) const;
84       void GetSignalValues(
85         unsigned long i, double& x, double& y, TPeak& p
86         ) const;
87
88     protected:
89       Mori( );
90       virtual ~Mori( );
91
92       virtual void _BeforeGenerateData( ) override;
93       virtual void _FinishOneLoop( ) override;
94       virtual void _ComputeOutputValue( TNode& n ) override;
95       virtual void _UpdateOutputValue( TNode& n ) override;
96       virtual void _QueueClear( ) override;
97       virtual TNode _QueuePop( ) override;
98       virtual void _QueuePush( const TNode& node ) override;
99       virtual unsigned long _QueueSize( ) const override;
100       virtual void _PrepareSeeds( TNodes& nodes ) override;
101
102     private:
103       // Purposely not implemented.
104       Mori( const Self& other );
105       Self& operator=( const Self& other );
106
107     protected:
108       typename TPredicate::Pointer m_Predicate;
109
110       TOutputValue m_InsideValue;
111       TInputValue  m_MinimumThreshold;
112       TThresholds  m_Thresholds;
113       typename TThresholds::const_iterator m_CurrThr;
114
115       TQueue       m_Queues[ 2 ];
116       unsigned int m_CurrQueue;
117       double       m_CurrCount;
118
119       TPeakDetector m_PeakDetector;
120     };
121
122   } // ecapseman
123
124 } // ecapseman
125
126 #ifndef ITK_MANUAL_INSTANTIATION
127 #  include <fpa/Base/Mori.hxx>
128 #endif // ITK_MANUAL_INSTANTIATION
129
130 #endif // __fpa__Base__Mori__h__
131
132 // eof - $RCSfile$