1 #include "ImageRegionGrow.h"
3 #include <cpPlugins/Interface/Image.h>
4 #include <fpaPlugins/GrowFunction.h>
5 #include <fpa/Image/RegionGrow.h>
6 #include <fpa/Image/Functors/RegionGrowAllBelongsFunction.h>
8 // -------------------------------------------------------------------------
9 fpaPlugins::ImageRegionGrow::
13 this->_AddInput( "GrowFunction", false );
15 this->m_Parameters->ConfigureAsReal( "InsideValue" );
16 this->m_Parameters->ConfigureAsReal( "OutsideValue" );
18 this->m_Parameters->SetReal( "InsideValue", 1 );
19 this->m_Parameters->SetReal( "OutsideValue", 0 );
22 // -------------------------------------------------------------------------
23 fpaPlugins::ImageRegionGrow::
28 // -------------------------------------------------------------------------
29 std::string fpaPlugins::ImageRegionGrow::
33 this->GetInputData< cpPlugins::Interface::Image >( "Input" );
34 itk::DataObject* image = NULL;
36 cpPlugins_Image_Demangle_AllScalarTypes( 2, input, image, r, _GD0 );
37 else cpPlugins_Image_Demangle_AllScalarTypes( 3, input, image, r, _GD0 );
38 else r = "fpaPlugins::ImageRegionGrow: Input image type not supported.";
42 // -------------------------------------------------------------------------
44 std::string fpaPlugins::ImageRegionGrow::
45 _GD0( itk::DataObject* data )
47 typedef unsigned char _TOutPixel;
48 typedef itk::Image< _TOutPixel, I::ImageDimension > _TOut;
49 typedef fpa::Image::RegionGrow< I, _TOut > _TFilter;
50 typedef typename _TFilter::TGrowingFunction _TFunctor;
53 _TFilter* filter = this->_ConfigureFilter< _TFilter >( );
55 // Connect grow functor (or create a tautology)
56 typename _TFunctor::Pointer functor;
57 auto functor_wrapper =
58 this->GetInputData< cpPlugins::Interface::DataObject >( "GrowFunction" );
59 if( functor_wrapper != NULL )
60 functor = functor_wrapper->GetITK< _TFunctor >( );
61 if( functor.IsNull( ) )
63 fpa::Image::Functors::RegionGrowAllBelongsFunction< I >::New( );
64 filter->SetGrowingFunction( functor );
66 // Set numeric parameters
67 filter->SetInsideValue(
68 _TOutPixel( this->m_Parameters->GetReal( "InsideValue" ) )
70 filter->SetOutsideValue(
71 _TOutPixel( this->m_Parameters->GetReal( "OutsideValue" ) )
75 this->_ExecuteFilter( filter );