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.ConfigureAsReal( "Step", 1 );
17 this->m_Parameters.ConfigureAsReal( "Lower", 0 );
18 this->m_Parameters.ConfigureAsReal( "Upper", 1 );
19 this->m_Parameters.ConfigureAsReal( "Sensitivity", 1 );
20 this->m_Parameters.ConfigureAsIntTypesChoices( "ResultType" );
23 // -------------------------------------------------------------------------
24 fpaPluginsImageAlgorithms::MoriRegionGrow::
29 // -------------------------------------------------------------------------
30 void fpaPluginsImageAlgorithms::MoriRegionGrow::
33 auto o = this->GetInputData( "Input" );
34 cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 )
35 this->_Error( "Invalid input image." );
38 // -------------------------------------------------------------------------
39 template< class _TImage >
40 void fpaPluginsImageAlgorithms::MoriRegionGrow::
41 _GD0( _TImage* image )
43 auto rtype = this->m_Parameters.GetSelectedChoice( "ResultType" );
44 if( rtype == "char" ) this->_GD1< _TImage, char >( image );
45 else if( rtype == "uchar" ) this->_GD1< _TImage, unsigned char >( image );
46 else if( rtype == "short" ) this->_GD1< _TImage, short >( image );
47 else if( rtype == "ushort" ) this->_GD1< _TImage, unsigned short >( image );
48 else if( rtype == "int" ) this->_GD1< _TImage, int >( image );
49 else if( rtype == "uint" ) this->_GD1< _TImage, unsigned int >( image );
50 else if( rtype == "long" ) this->_GD1< _TImage, long >( image );
51 else if( rtype == "ulong" ) this->_GD1< _TImage, unsigned long >( image );
52 else this->_GD1< _TImage, char >( image );
55 // -------------------------------------------------------------------------
56 template< class _TInputImage, class _TOutputPixel >
57 void fpaPluginsImageAlgorithms::MoriRegionGrow::
58 _GD1( _TInputImage* image )
61 itk::Image< _TOutputPixel, _TInputImage::ImageDimension >
63 typedef fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage > _TFilter;
65 auto filter = this->_CreateITK< _TFilter >( );
66 this->_ConfigureFilter( filter, image );
67 filter->SetInsideValue( this->m_Parameters.GetInt( "InsideValue" ) );
68 filter->SetOutsideValue( this->m_Parameters.GetInt( "OutsideValue" ) );
69 filter->SetStep( this->m_Parameters.GetReal( "Step" ) );
70 filter->SetLower( this->m_Parameters.GetReal( "Lower" ) );
71 filter->SetUpper( this->m_Parameters.GetReal( "Upper" ) );
72 filter->SetSensitivity( this->m_Parameters.GetReal( "Sensitivity" ) );
74 this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );