]> Creatis software - FrontAlgorithms.git/blob - plugins/ImageAlgorithms/MoriRegionGrow.cxx
Mori is alivegit status!
[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.ConfigureAsInt( "Step", 1 );
17   this->m_Parameters.ConfigureAsReal( "LowerThreshold", 1 );
18   this->m_Parameters.ConfigureAsReal( "UpperThreshold", 1 );
19   this->m_Parameters.ConfigureAsIntTypesChoices( "ResultType" );
20 }
21
22 // -------------------------------------------------------------------------
23 fpaPluginsImageAlgorithms::MoriRegionGrow::
24 ~MoriRegionGrow( )
25 {
26 }
27
28 // -------------------------------------------------------------------------
29 void fpaPluginsImageAlgorithms::MoriRegionGrow::
30 _GenerateData( )
31 {
32   auto o = this->GetInputData( "Input" );
33   cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 )
34     this->_Error( "Invalid input image." );
35 }
36
37 // -------------------------------------------------------------------------
38 template< class _TImage >
39 void fpaPluginsImageAlgorithms::MoriRegionGrow::
40 _GD0( _TImage* image )
41 {
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 );
52 }
53
54 // -------------------------------------------------------------------------
55 template< class _TInputImage, class _TOutputPixel >
56 void fpaPluginsImageAlgorithms::MoriRegionGrow::
57 _GD1( _TInputImage* image )
58 {
59   typedef
60     itk::Image< _TOutputPixel, _TInputImage::ImageDimension >
61     _TOutputImage;
62   typedef fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage > _TFilter;
63   typedef typename _TFilter::TGrowFunction                      _TGrow;
64
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" ) );
70   filter->Update( );
71   this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
72 }
73
74 // eof - $RCSfile$