1 #include <ImageAlgorithms/MoriRegionGrow.h>
2 #include <cpInstances/DataObjects/Image.h>
4 #include <fpa/Image/MoriRegionGrow.h>
6 // -------------------------------------------------------------------------
7 fpaPluginsImageAlgorithms::MoriRegionGrow::
11 typedef cpPlugins::Pipeline::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.ConfigureAsInt( "Step", 1 );
17 this->m_Parameters.ConfigureAsReal( "LowerThreshold", 1 );
18 this->m_Parameters.ConfigureAsReal( "UpperThreshold", 1 );
19 this->m_Parameters.ConfigureAsIntTypesChoices( "ResultType" );
22 // -------------------------------------------------------------------------
23 fpaPluginsImageAlgorithms::MoriRegionGrow::
28 // -------------------------------------------------------------------------
29 void fpaPluginsImageAlgorithms::MoriRegionGrow::
32 auto o = this->GetInputData( "Input" );
33 cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 )
34 this->_Error( "Invalid input image." );
37 // -------------------------------------------------------------------------
38 template< class _TImage >
39 void fpaPluginsImageAlgorithms::MoriRegionGrow::
40 _GD0( _TImage* image )
42 auto rtype = this->m_Parameters.GetSelectedChoice( "ResultType" );
43 if( rtype == "char" ) this->_GD1< _TImage, char >( image );
44 else if( rtype == "uchar" ) this->_GD1< _TImage, unsigned char >( image );
45 else if( rtype == "short" ) this->_GD1< _TImage, short >( image );
46 else if( rtype == "ushort" ) this->_GD1< _TImage, unsigned short >( image );
47 else if( rtype == "int" ) this->_GD1< _TImage, int >( image );
48 else if( rtype == "uint" ) this->_GD1< _TImage, unsigned int >( image );
49 else if( rtype == "long" ) this->_GD1< _TImage, long >( image );
50 else if( rtype == "ulong" ) this->_GD1< _TImage, unsigned long >( image );
51 else this->_GD1< _TImage, char >( image );
54 // -------------------------------------------------------------------------
55 template< class _TInputImage, class _TOutputPixel >
56 void fpaPluginsImageAlgorithms::MoriRegionGrow::
57 _GD1( _TInputImage* image )
60 itk::Image< _TOutputPixel, _TInputImage::ImageDimension >
62 typedef fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage > _TFilter;
63 typedef typename _TFilter::TGrowFunction _TGrow;
65 auto filter = this->_CreateITK< _TFilter >( );
66 this->_ConfigureFilter( filter, image );
67 filter->SetGrowFunction( this->GetInputData< _TGrow >( "GrowFunction" ) );
68 filter->SetInsideValue( this->m_Parameters.GetInt( "InsideValue" ) );
69 filter->SetOutsideValue( this->m_Parameters.GetInt( "OutsideValue" ) );
71 this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );