1 #include <ImageAlgorithms/RegionGrow.h>
2 #include <cpInstances/Image.h>
4 #include <fpa/Image/RegionGrow.h>
6 // -------------------------------------------------------------------------
7 fpaPluginsImageAlgorithms::RegionGrow::
11 typedef cpPlugins::BaseObjects::DataObject _TData;
13 this->_ConfigureInput< _TData >( "GrowFunction", true, false );
14 this->m_Parameters.ConfigureAsInt( "InsideValue", 1 );
15 this->m_Parameters.ConfigureAsInt( "OutsideValue", 0 );
16 this->m_Parameters.ConfigureAsIntTypesChoices( "ResultType" );
19 // -------------------------------------------------------------------------
20 fpaPluginsImageAlgorithms::RegionGrow::
25 // -------------------------------------------------------------------------
26 void fpaPluginsImageAlgorithms::RegionGrow::
29 auto o = this->GetInputData( "Input" );
30 cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 )
31 this->_Error( "Invalid input image." );
34 // -------------------------------------------------------------------------
35 template< class _TImage >
36 void fpaPluginsImageAlgorithms::RegionGrow::
37 _GD0( _TImage* image )
39 auto rtype = this->m_Parameters.GetSelectedChoice( "ResultType" );
40 if( rtype == "char" ) this->_GD1< _TImage, char >( image );
41 else if( rtype == "uchar" ) this->_GD1< _TImage, unsigned char >( image );
42 else if( rtype == "short" ) this->_GD1< _TImage, short >( image );
43 else if( rtype == "ushort" ) this->_GD1< _TImage, unsigned short >( image );
44 else if( rtype == "int" ) this->_GD1< _TImage, int >( image );
45 else if( rtype == "uint" ) this->_GD1< _TImage, unsigned int >( image );
46 else if( rtype == "long" ) this->_GD1< _TImage, long >( image );
47 else if( rtype == "ulong" ) this->_GD1< _TImage, unsigned long >( image );
48 else this->_GD1< _TImage, char >( image );
51 // -------------------------------------------------------------------------
52 template< class _TInputImage, class _TOutputPixel >
53 void fpaPluginsImageAlgorithms::RegionGrow::
54 _GD1( _TInputImage* image )
57 itk::Image< _TOutputPixel, _TInputImage::ImageDimension >
59 typedef fpa::Image::RegionGrow< _TInputImage, _TOutputImage > _TFilter;
60 typedef typename _TFilter::TGrowFunction _TGrow;
62 auto filter = this->_CreateITK< _TFilter >( );
63 this->_ConfigureFilter( filter, image );
64 filter->SetGrowFunction( this->GetInputData< _TGrow >( "GrowFunction" ) );
65 filter->SetInsideValue( this->m_Parameters.GetInt( "InsideValue" ) );
66 filter->SetOutsideValue( this->m_Parameters.GetInt( "OutsideValue" ) );
68 this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );