]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Image/RegionGrow.h
Minor bugs
[FrontAlgorithms.git] / lib / fpa / Image / RegionGrow.h
1 #ifndef __FPA__IMAGE__REGIONGROW__H__
2 #define __FPA__IMAGE__REGIONGROW__H__
3
4 #include <itkImageToImageFilter.h>
5 #include <itkIndex.h>
6 #include <fpa/Base/RegionGrow.h>
7 #include <fpa/Image/Algorithm.h>
8 #include <fpa/Image/Functors/ImageFunction.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
35       fpa::Image::Functors::ImageFunction< I, bool >
36       TMembershipFunction;
37
38     public:
39       itkNewMacro( Self );
40       itkTypeMacro( RegionGrow, fpaBaseRegionGrow );
41
42       itkGetObjectMacro( MembershipFunction, TMembershipFunction );
43       itkSetObjectMacro( MembershipFunction, TMembershipFunction );
44
45     protected:
46       RegionGrow( )
47         : Superclass( ),
48           m_MembershipFunction( NULL )
49         { }
50       virtual ~RegionGrow( )
51         { }
52
53       virtual bool _CheckMembership(
54         const typename Superclass::_TNode& n
55         ) const
56         {
57           if( this->m_MembershipFunction.IsNotNull( ) )
58           {
59             if(
60               this->m_MembershipFunction->GetInputImage( ) !=
61               this->GetInput( )
62               )
63               this->m_MembershipFunction->SetInputImage( this->GetInput( ) );
64             return( this->m_MembershipFunction->Evaluate( n.Vertex ) );
65           }
66           else
67             return( false );
68         }
69
70     private:
71       // Purposely not implemented
72       RegionGrow( const Self& );
73       void operator=( const Self& );
74
75     protected:
76       typename TMembershipFunction::Pointer m_MembershipFunction;
77     };
78
79   } // ecapseman
80
81 } // ecapseman
82
83 #endif // __FPA__IMAGE__REGIONGROW__H__
84
85 // eof - $RCSfile$