]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Base/Mori.h
e7ea726eab3c61809d5c7f2b8f9e1cc878ee5b61
[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 #include <ivq/ITK/PeakDetector.h>
14 #include <fpa/Config.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::TTraits TTraits;
34       fpa_Base_TraitTypes( typename TTraits );
35
36       /* TODO
37          typedef typename _TAlgorithm::TNode        TNode;
38          typedef typename _TAlgorithm::TNodes       TNodes;
39          typedef typename _TAlgorithm::TInputValue  TInputValue;
40          typedef typename _TAlgorithm::TOutputValue TOutputValue;
41          typedef typename _TAlgorithm::TFrontId     TFrontId;
42          typedef typename _TAlgorithm::TVertex      TVertex;
43       */
44
45       typedef std::deque< TNode >     TQueue;
46       typedef std::set< TInputValue > TThresholds;
47
48       typedef ivq::ITK::PeakDetector TPeakDetector;
49       typedef TPeakDetector::TPeak   TPeak;
50
51       typedef fpa::Base::Functors::RegionGrow::BinaryThreshold< TInputValue > TPredicate;
52
53     public:
54       itkConceptMacro(
55         Check_TOutputValue,
56         ( itk::Concept::IsUnsignedInteger< TOutputValue > )
57         );
58
59       itkGetConstMacro( InsideValue, TOutputValue );
60       itkSetMacro( InsideValue, TOutputValue );
61
62       itkGetConstMacro( MinimumThreshold, TInputValue );
63       itkSetMacro( MinimumThreshold, TInputValue );
64
65     public:
66       virtual itk::ModifiedTimeType GetMTime( ) const override;
67
68       TOutputValue GetOutsideValue( ) const;
69       void SetOutsideValue( const TOutputValue& v );
70
71       unsigned long GetSignalKernelSize( ) const;
72       double GetSignalThreshold( ) const;
73       double GetSignalInfluence( ) const;
74
75       void SetSignalKernelSize( unsigned long k );
76       void SetSignalThreshold( double t );
77       void SetSignalInfluence( double i );
78
79       void ClearThresholds( );
80       void AddThreshold( const TInputValue& thr );
81       void SetThresholds(
82         const TInputValue& init,
83         const TInputValue& end,
84         const TInputValue& delta
85         );
86       const TThresholds& GetThresholds( ) const;
87       unsigned long GetNumberOfEvaluatedThresholds( ) const;
88       TInputValue GetOptimumThreshold( ) const;
89       void GetSignalValues(
90         unsigned long i, double& x, double& y, TPeak& p
91         ) const;
92
93     protected:
94       Mori( );
95       virtual ~Mori( );
96
97       virtual void _BeforeGenerateData( ) override;
98       virtual void _FinishOneLoop( ) override;
99       virtual void _ComputeOutputValue( TNode& n ) override;
100       virtual void _UpdateOutputValue( TNode& n ) override;
101       virtual void _QueueClear( ) override;
102       virtual TNode _QueuePop( ) override;
103       virtual void _QueuePush( const TNode& node ) override;
104       virtual unsigned long _QueueSize( ) const override;
105       virtual void _PrepareSeeds( TNodes& nodes ) override;
106
107     private:
108       // Purposely not implemented.
109       Mori( const Self& other );
110       Self& operator=( const Self& other );
111
112     protected:
113       typename TPredicate::Pointer m_Predicate;
114
115       TOutputValue m_InsideValue;
116       TInputValue  m_MinimumThreshold;
117       TThresholds  m_Thresholds;
118       typename TThresholds::const_iterator m_CurrThr;
119
120       TQueue       m_Queues[ 2 ];
121       unsigned int m_CurrQueue;
122       double       m_CurrCount;
123
124       TPeakDetector m_PeakDetector;
125     };
126
127   } // ecapseman
128
129 } // ecapseman
130
131 #ifndef ITK_MANUAL_INSTANTIATION
132 #  include <fpa/Base/Mori.hxx>
133 #endif // ITK_MANUAL_INSTANTIATION
134
135 #endif // __fpa__Base__Mori__h__
136
137 // eof - $RCSfile$