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