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::
32 auto input = this->GetInputData( "Input" );
33 itk::DataObject* image = NULL;
35 cpPlugins_Image_Demangle_AllScalarTypes( 2, input, image, r, _GD0 );
36 else cpPlugins_Image_Demangle_AllScalarTypes( 3, input, image, r, _GD0 );
37 else r = "fpaPlugins::ImageRegionGrow: Input image type not supported.";
41 // -------------------------------------------------------------------------
43 std::string fpaPlugins::ImageRegionGrow::
44 _GD0( itk::DataObject* data )
46 typedef unsigned char _TOutPixel;
47 typedef itk::Image< _TOutPixel, I::ImageDimension > _TOut;
48 typedef fpa::Image::RegionGrow< I, _TOut > _TFilter;
49 typedef typename _TFilter::TGrowingFunction _TFunctor;
52 _TFilter* filter = this->_ConfigureFilter< _TFilter >( );
54 // Connect grow functor (or create a tautology)
55 typename _TFunctor::Pointer functor;
56 auto functor_wrapper = this->GetInputData( "GrowFunction" );
57 if( functor_wrapper != NULL )
58 functor = functor_wrapper->GetITK< _TFunctor >( );
59 if( functor.IsNull( ) )
61 fpa::Image::Functors::RegionGrowAllBelongsFunction< I >::New( );
62 filter->SetGrowingFunction( functor );
64 // Set numeric parameters
65 filter->SetInsideValue(
66 _TOutPixel( this->m_Parameters->GetReal( "InsideValue" ) )
68 filter->SetOutsideValue(
69 _TOutPixel( this->m_Parameters->GetReal( "OutsideValue" ) )
73 this->_ExecuteFilter( filter );