]> Creatis software - FrontAlgorithms.git/blob - libs/fpa/Image/MoriRegionGrow.h
...
[FrontAlgorithms.git] / libs / fpa / Image / MoriRegionGrow.h
1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5
6 #ifndef __fpa__Image__MoriRegionGrow__h__
7 #define __fpa__Image__MoriRegionGrow__h__
8
9 #include <itkImageToImageFilter.h>
10 #include <itkBinaryThresholdImageFilter.h>
11
12 namespace fpa
13 {
14   namespace Image
15   {
16     /**
17      */
18     template< class _TInputImage, class _TOutputImage, class _TAuxiliaryPixel = unsigned short >
19     class MoriRegionGrow
20       : public itk::ImageToImageFilter< _TInputImage, _TOutputImage >
21     {
22     public:
23       typedef _TInputImage  TInputImage;
24       typedef _TOutputImage TOutputImage;
25       typedef _TAuxiliaryPixel TAuxiliaryPixel;
26       typedef itk::Image< TAuxiliaryPixel, TInputImage::ImageDimension > TAuxiliaryImage;
27
28       typedef MoriRegionGrow                                             Self;
29       typedef itk::ImageToImageFilter< TInputImage, TOutputImage > Superclass;
30       typedef itk::SmartPointer< Self >                               Pointer;
31       typedef itk::SmartPointer< const Self >                    ConstPointer;
32
33       typedef typename TInputImage::IndexType  TIndex;
34       typedef typename TInputImage::RegionType TRegion;
35       typedef typename TInputImage::PixelType  TInputPixel;
36       typedef typename TOutputImage::PixelType TOutputPixel;
37
38       struct TCurveData
39       {
40         TInputPixel XValue;
41         unsigned long YValue;
42         double Diff1;
43         TCurveData( TInputPixel v, unsigned long c )
44           {
45             this->XValue = v;
46             this->YValue = c;
47             this->Diff1 = double( 0 );
48           }
49       };
50       typedef std::vector< TCurveData > TCurve;
51       typedef itk::BinaryThresholdImageFilter< TAuxiliaryImage, TOutputImage > TThresholdFilter;
52
53     public:
54       itkNewMacro( Self );
55       itkTypeMacro( fpa::Image::MoriRegionGrow, itk::ImageToImageFilter );
56
57       itkGetConstMacro( Seed, TIndex );
58       itkGetConstMacro( InsideValue, TOutputPixel );
59       itkGetConstMacro( OutsideValue, TOutputPixel );
60       itkGetConstMacro( LowerThreshold, TInputPixel );
61       itkGetConstMacro( UpperThreshold, TInputPixel );
62       itkGetConstMacro( DeltaThreshold, TInputPixel );
63       itkGetConstMacro( OptimumThreshold, TInputPixel );
64       itkGetConstMacro( Curve, TCurve );
65
66       itkSetMacro( Seed, TIndex );
67       itkSetMacro( InsideValue, TOutputPixel );
68       itkSetMacro( OutsideValue, TOutputPixel );
69       itkSetMacro( LowerThreshold, TInputPixel );
70       itkSetMacro( UpperThreshold, TInputPixel );
71       itkSetMacro( DeltaThreshold, TInputPixel );
72
73     public:
74       TAuxiliaryImage* GetAuxiliaryImage( );
75       const TAuxiliaryImage* GetAuxiliaryImage( ) const;
76
77       void SetThresholdRange(
78         const TInputPixel& lower, const TInputPixel& upper,
79         const TInputPixel& delta = TInputPixel( 1 )
80         );
81
82     protected:
83       MoriRegionGrow( );
84       virtual ~MoriRegionGrow( );
85
86       virtual void GenerateInputRequestedRegion( ) override;
87       virtual void EnlargeOutputRequestedRegion(
88         itk::DataObject* output
89         ) override;
90       virtual void GenerateData( ) override;
91
92     private:
93       // Purposely not implemented
94       MoriRegionGrow( const Self& other );
95       Self& operator=( const Self& other );
96
97     protected:
98       TIndex       m_Seed;
99       TOutputPixel m_InsideValue;
100       TOutputPixel m_OutsideValue;
101       TInputPixel  m_LowerThreshold;
102       TInputPixel  m_UpperThreshold;
103       TInputPixel  m_DeltaThreshold;
104       TInputPixel  m_OptimumThreshold;
105
106       TCurve m_Curve;
107       typename TThresholdFilter::Pointer m_ThresholdFilter;
108     };
109
110   } // ecapseman
111
112 } // ecapseman
113
114 #ifndef ITK_MANUAL_INSTANTIATION
115 #  include <fpa/Image/MoriRegionGrow.hxx>
116 #endif // ITK_MANUAL_INSTANTIATION
117
118 #endif // __fpa__Image__MoriRegionGrow__h__
119
120 // eof - $RCSfile$