]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Image/RegionGrowWithMultipleThresholds.h
f538e7bb49734f4bcbf9508a5e404269982bc211
[FrontAlgorithms.git] / lib / fpa / Image / RegionGrowWithMultipleThresholds.h
1 #ifndef __FPA__IMAGE__REGIONGROWWITHMULTIPLETHRESHOLDS__H__
2 #define __FPA__IMAGE__REGIONGROWWITHMULTIPLETHRESHOLDS__H__
3
4 #include <map>
5 #include <set>
6 #include <fpa/Image/RegionGrowWithMultipleCriteria.h>
7 #include <fpa/Image/Functors/RegionGrowThresholdFunction.h>
8
9 namespace fpa
10 {
11   namespace Image
12   {
13     /**
14      * @param I Input image type
15      */
16     template< class I >
17     class RegionGrowWithMultipleThresholds
18       : public RegionGrowWithMultipleCriteria< I >
19     {
20     public:
21       typedef RegionGrowWithMultipleThresholds    Self;
22       typedef RegionGrowWithMultipleCriteria< I > Superclass;
23       typedef itk::SmartPointer< Self >           Pointer;
24       typedef itk::SmartPointer< const Self >     ConstPointer;
25
26       typedef typename I::PixelType TPixel;
27
28       typedef std::map< TPixel, unsigned long >        THistogram;
29       typedef typename Superclass::TBaseAlgorithm      TBaseAlgorithm;
30       typedef typename Superclass::TMembershipFunction TMembershipFunction;
31       typedef typename Superclass::TFunctions          TFunctions;
32
33       typedef std::set< TPixel >                                   TThresholds;
34       typedef fpa::Image::Functors::RegionGrowThresholdFunction< I > TFunction;
35
36     protected:
37       typedef typename TBaseAlgorithm::_TNode _TNode;
38
39     public:
40       itkNewMacro( Self );
41       itkTypeMacro( RegionGrowWithMultipleThresholds, RegionGrow );
42
43       itkGetConstMacro( InsideValue, TPixel );
44       itkGetConstMacro( OutsideValue, TPixel );
45       itkGetConstMacro( DifferenceThreshold, double );
46
47       itkSetMacro( InsideValue, TPixel );
48       itkSetMacro( OutsideValue, TPixel );
49       itkSetMacro( DifferenceThreshold, double );
50
51     public:
52       void AddThreshold( const TPixel& v );
53       void AddThresholds(
54         const TPixel& t0,
55         const TPixel& t1,
56         const unsigned int& s
57         );
58
59     protected:
60       RegionGrowWithMultipleThresholds( );
61       virtual ~RegionGrowWithMultipleThresholds( );
62
63       virtual void _BeforeMainLoop( );
64       virtual void _AfterMainLoop( );
65       virtual void _AfterLoop( );
66       virtual bool _UpdateResult( _TNode& n );
67       virtual void _Mark( const _TNode& n );
68       virtual bool _CheckStopCondition( );
69
70     private:
71       RegionGrowWithMultipleThresholds( const Self& ); // Not impl.
72       void operator=( const Self& );                   // Not impl.
73
74     protected:
75       TThresholds m_Thresholds;
76       TPixel m_InsideValue;
77       TPixel m_OutsideValue;
78       double m_DifferenceThreshold;
79       THistogram m_Histogram;
80       unsigned long m_TotalCount;
81       double m_LastDiff;
82       bool m_StopForced;
83       TPixel m_StopThreshold;
84     };
85
86   } // ecapseman
87
88 } // ecapseman
89
90 #ifndef ITK_MANUAL_INSTANTIATION
91 #include <fpa/Image/RegionGrowWithMultipleThresholds.hxx>
92 #endif // ITK_MANUAL_INSTANTIATION
93
94 #endif // __FPA__IMAGE__REGIONGROWWITHMULTIPLETHRESHOLDS__H__
95
96 // eof - $RCSfile$