1 #include "ImageRegionGrow.h"
3 #include <cpPlugins/Image.h>
4 #include <fpa_Instances/Filters.h>
6 // -------------------------------------------------------------------------
7 fpaPlugins::ImageRegionGrow::
11 this->_AddInput( "GrowFunctor", false );
12 this->m_Parameters.ConfigureAsUint( "InsideValue" );
13 this->m_Parameters.ConfigureAsUint( "OutsideValue" );
14 this->m_Parameters.SetUint( "InsideValue", 1 );
15 this->m_Parameters.SetUint( "OutsideValue", 0 );
18 // -------------------------------------------------------------------------
19 fpaPlugins::ImageRegionGrow::
24 // -------------------------------------------------------------------------
25 void fpaPlugins::ImageRegionGrow::
28 auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( );
29 cpPlugins_Image_Demangle_Pixel_AllScalars ( _GD0, image, 2 );
30 else cpPlugins_Image_Demangle_Pixel_AllScalars( _GD0, image, 3 );
31 else this->_Error( "No valid input image." );
34 // -------------------------------------------------------------------------
35 template< class _TImage >
36 void fpaPlugins::ImageRegionGrow::
37 _GD0( _TImage* image )
39 typedef unsigned short _TPixel;
40 typedef itk::Image< _TPixel, _TImage::ImageDimension > _TOutImage;
41 typedef fpa::Image::RegionGrow< _TImage, _TOutImage > _TFilter;
42 typedef typename _TFilter::TGrowingFunction _TGrowFunctor;
43 typedef typename _TFilter::TResult _TResult;
46 _TFilter* filter = this->_ConfigureFilter< _TFilter >( );
48 typename _TGrowFunctor::Pointer functor;
49 auto wrap_functor = this->GetInputData( "GrowFunctor" );
50 if( wrap_functor != NULL )
51 functor = wrap_functor->GetITK< _TGrowFunctor >( );
52 if( functor.IsNull( ) )
53 filter->SetGrowingFunction( functor );
54 filter->SetInsideValue(
55 _TResult( this->m_Parameters.GetUint( "InsideValue" ) )
57 filter->SetOutsideValue(
58 _TResult( this->m_Parameters.GetUint( "OutsideValue" ) )
62 this->_ExecuteFilter( filter );
64 // Connect remaining output
65 this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) );