]> Creatis software - FrontAlgorithms.git/blob - plugins/ImageAlgorithms/MoriRegionGrow.cxx
1a499791e8794bdd46a1f9620ca3a69e33f04041
[FrontAlgorithms.git] / plugins / ImageAlgorithms / MoriRegionGrow.cxx
1 #include <ImageAlgorithms/MoriRegionGrow.h>
2 #include <cpInstances/DataObjects/Image.h>
3
4 #include <fpa/Image/MoriRegionGrow.h>
5
6 // -------------------------------------------------------------------------
7 fpaPluginsImageAlgorithms::MoriRegionGrow::
8 MoriRegionGrow( )
9   : Superclass( )
10 {
11   typedef cpPlugins::Pipeline::DataObject _TData;
12
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" );
21 }
22
23 // -------------------------------------------------------------------------
24 fpaPluginsImageAlgorithms::MoriRegionGrow::
25 ~MoriRegionGrow( )
26 {
27 }
28
29 // -------------------------------------------------------------------------
30 void fpaPluginsImageAlgorithms::MoriRegionGrow::
31 _GenerateData( )
32 {
33   auto o = this->GetInputData( "Input" );
34   cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 )
35     this->_Error( "Invalid input image." );
36 }
37
38 // -------------------------------------------------------------------------
39 template< class _TImage >
40 void fpaPluginsImageAlgorithms::MoriRegionGrow::
41 _GD0( _TImage* image )
42 {
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 );
53 }
54
55 // -------------------------------------------------------------------------
56 template< class _TInputImage, class _TOutputPixel >
57 void fpaPluginsImageAlgorithms::MoriRegionGrow::
58 _GD1( _TInputImage* image )
59 {
60   typedef
61     itk::Image< _TOutputPixel, _TInputImage::ImageDimension >
62     _TOutputImage;
63   typedef fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage > _TFilter;
64
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" ) );
73   filter->Update( );
74   this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
75 }
76
77 // eof - $RCSfile$