]> Creatis software - FrontAlgorithms.git/blob - plugins/fpa/ImageRegionGrow.cxx
...
[FrontAlgorithms.git] / plugins / fpa / ImageRegionGrow.cxx
1 #include "ImageRegionGrow.h"
2
3 #include <cpPlugins/Image.h>
4 #include <fpa/Image/RegionGrow.h>
5 #include <fpa/Base/RegionGrow.hxx>
6 #include <fpa/Image/RegionGrow.hxx>
7 #include <fpa/Base/Algorithm.hxx>
8 #include <fpa/Image/Algorithm.hxx>
9 #include <fpa/Image/Functors/RegionGrowAllBelongsFunction.h>
10
11 // -------------------------------------------------------------------------
12 fpaPlugins::ImageRegionGrow::
13 ImageRegionGrow( )
14   : Superclass( )
15 {
16   this->_AddInput( "GrowFunctor", false );
17   this->m_Parameters.ConfigureAsUint( "InsideValue" );
18   this->m_Parameters.ConfigureAsUint( "OutsideValue" );
19   this->m_Parameters.SetUint( "InsideValue", 1 );
20   this->m_Parameters.SetUint( "OutsideValue", 0 );
21 }
22
23 // -------------------------------------------------------------------------
24 fpaPlugins::ImageRegionGrow::
25 ~ImageRegionGrow( )
26 {
27 }
28
29 // -------------------------------------------------------------------------
30 std::string fpaPlugins::ImageRegionGrow::
31 _GenerateData( )
32 {
33   auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( );
34   std::string   cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 2 );
35   if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 3 );
36   return( r );
37 }
38
39 // -------------------------------------------------------------------------
40 template< class _TImage >
41 std::string fpaPlugins::ImageRegionGrow::
42 _GD0( _TImage* image )
43 {
44   typedef fpa::Image::RegionGrow< _TImage, _TImage > _TFilter;
45   typedef typename _TFilter::TGrowingFunction        _TGrowFunctor;
46   typedef typename _TFilter::TResult                 _TResult;
47
48   if( image == NULL )
49     return( "fpaPlugins::ImageRegionGrow: Invalid image type." );
50
51   // Get functor (if any)
52   typename _TGrowFunctor::Pointer functor;
53   auto wrap_functor = this->GetInputData( "GrowFunctor" );
54   if( wrap_functor != NULL )
55     functor = wrap_functor->GetITK< _TGrowFunctor >( );
56   if( functor.IsNull( ) )
57     functor =
58       fpa::Image::Functors::RegionGrowAllBelongsFunction< _TImage >::New( );
59
60   // Create filter
61   _TFilter* filter = this->_ConfigureFilter< _TFilter >( );
62   filter->SetGrowingFunction( functor );
63   filter->SetInsideValue(
64     _TResult( this->m_Parameters.GetUint( "InsideValue" ) )
65     );
66   filter->SetOutsideValue(
67     _TResult( this->m_Parameters.GetUint( "OutsideValue" ) )
68     );
69
70   // Go!!!
71   this->_ExecuteFilter( filter );
72
73   // Connect remaining output
74   this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) );
75   return( "" );
76 }
77
78 // eof - $RCSfile$