]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Image/RegionGrow.h
d65fa6cbbe815e9a3b3c21a290cc18357cec4421
[FrontAlgorithms.git] / lib / fpa / Image / RegionGrow.h
1 #ifndef __FPA__IMAGE__REGIONGROW__H__
2 #define __FPA__IMAGE__REGIONGROW__H__
3
4 #include <itkImageFunction.h>
5 #include <itkImageToImageFilter.h>
6 #include <itkIndex.h>
7 #include <fpa/Base/RegionGrow.h>
8 #include <fpa/Image/Algorithm.h>
9
10 namespace fpa
11 {
12   namespace Image
13   {
14     /**
15      * @param I Input image type
16      */
17     template< class I >
18     class RegionGrow
19       : public Algorithm< I, fpa::Base::RegionGrow< typename I::IndexType, typename I::PixelType, typename I::PixelType, itk::Functor::IndexLexicographicCompare< I::ImageDimension >, itk::ImageToImageFilter< I, I > > >
20     {
21     public:
22       // Standard class typdedefs
23       typedef typename I::IndexType TVertex;
24       typedef typename I::PixelType TResult;
25       typedef typename I::PixelType TVertexValue;
26       typedef itk::ImageToImageFilter< I, I > TBaseFilter;
27       typedef fpa::Base::RegionGrow< TVertex, TResult, TVertexValue, itk::Functor::IndexLexicographicCompare< I::ImageDimension >, TBaseFilter > TBaseAlgorithm;
28
29       typedef RegionGrow                      Self;
30       typedef Algorithm< I, TBaseAlgorithm >  Superclass;
31       typedef itk::SmartPointer< Self >       Pointer;
32       typedef itk::SmartPointer< const Self > ConstPointer;
33
34       typedef itk::ImageFunction< I, bool > TMembershipFunction;
35
36     public:
37       itkNewMacro( Self );
38       itkTypeMacro( RegionGrow, fpaBaseRegionGrow );
39
40       itkGetObjectMacro( MembershipFunction, TMembershipFunction );
41       itkSetObjectMacro( MembershipFunction, TMembershipFunction );
42
43     protected:
44       RegionGrow( )
45         : Superclass( ),
46           m_MembershipFunction( NULL )
47         { }
48       virtual ~RegionGrow( )
49         { }
50
51       virtual bool _CheckMembership(
52         const typename Superclass::_TNode& n
53         ) const
54         {
55           if( this->m_MembershipFunction.IsNotNull( ) )
56           {
57             if(
58               this->m_MembershipFunction->GetInputImage( ) !=
59               this->GetInput( )
60               )
61               this->m_MembershipFunction->SetInputImage( this->GetInput( ) );
62             return( this->m_MembershipFunction->EvaluateAtIndex( n.Vertex ) );
63           }
64           else
65             return( false );
66         }
67
68     private:
69       // Purposely not implemented
70       RegionGrow( const Self& );
71       void operator=( const Self& );
72
73     protected:
74       typename TMembershipFunction::Pointer m_MembershipFunction;
75     };
76
77   } // ecapseman
78
79 } // ecapseman
80
81 #endif // __FPA__IMAGE__REGIONGROW__H__
82
83 // eof - $RCSfile$