1 #include "ImageRegionGrow.h"
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>
11 // -------------------------------------------------------------------------
12 fpaPlugins::ImageRegionGrow::
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 );
23 // -------------------------------------------------------------------------
24 fpaPlugins::ImageRegionGrow::
29 // -------------------------------------------------------------------------
30 std::string fpaPlugins::ImageRegionGrow::
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 );
39 // -------------------------------------------------------------------------
40 template< class _TImage >
41 std::string fpaPlugins::ImageRegionGrow::
42 _GD0( _TImage* image )
44 typedef fpa::Image::RegionGrow< _TImage, _TImage > _TFilter;
45 typedef typename _TFilter::TGrowingFunction _TGrowFunctor;
46 typedef typename _TFilter::TResult _TResult;
49 return( "fpaPlugins::ImageRegionGrow: Invalid image type." );
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( ) )
58 fpa::Image::Functors::RegionGrowAllBelongsFunction< _TImage >::New( );
61 _TFilter* filter = this->_ConfigureFilter< _TFilter >( );
62 filter->SetGrowingFunction( functor );
63 filter->SetInsideValue(
64 _TResult( this->m_Parameters.GetUint( "InsideValue" ) )
66 filter->SetOutsideValue(
67 _TResult( this->m_Parameters.GetUint( "OutsideValue" ) )
71 this->_ExecuteFilter( filter );
73 // Connect remaining output
74 this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) );