]> Creatis software - FrontAlgorithms.git/blob - plugins/ImageAlgorithms/RegionGrow.cxx
...
[FrontAlgorithms.git] / plugins / ImageAlgorithms / RegionGrow.cxx
1 #include <ImageAlgorithms/RegionGrow.h>
2 #include <cpInstances/Image.h>
3
4 #include <fpa/Image/RegionGrow.h>
5
6 // -------------------------------------------------------------------------
7 fpaPluginsImageAlgorithms::RegionGrow::
8 RegionGrow( )
9   : Superclass( )
10 {
11   typedef cpPlugins::BaseObjects::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.ConfigureAsIntTypesChoices( "ResultType" );
17 }
18
19 // -------------------------------------------------------------------------
20 fpaPluginsImageAlgorithms::RegionGrow::
21 ~RegionGrow( )
22 {
23 }
24
25 // -------------------------------------------------------------------------
26 void fpaPluginsImageAlgorithms::RegionGrow::
27 _GenerateData( )
28 {
29   auto o = this->GetInputData( "Input" );
30   cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 )
31     this->_Error( "Invalid input image." );
32 }
33
34 // -------------------------------------------------------------------------
35 template< class _TImage >
36 void fpaPluginsImageAlgorithms::RegionGrow::
37 _GD0( _TImage* image )
38 {
39   auto rtype = this->m_Parameters.GetSelectedChoice( "ResultType" );
40   if( rtype == "char" ) this->_GD1< _TImage, char >( image );
41   if( rtype == "uchar" ) this->_GD1< _TImage, unsigned char >( image );
42   if( rtype == "short" ) this->_GD1< _TImage, short >( image );
43   if( rtype == "ushort" ) this->_GD1< _TImage, unsigned short >( image );
44   if( rtype == "int" ) this->_GD1< _TImage, int >( image );
45   if( rtype == "uint" ) this->_GD1< _TImage, unsigned int >( image );
46   if( rtype == "long" ) this->_GD1< _TImage, long >( image );
47   if( rtype == "ulong" ) this->_GD1< _TImage, unsigned long >( image );
48 }
49
50 // -------------------------------------------------------------------------
51 template< class _TInputImage, class _TOutputPixel >
52 void fpaPluginsImageAlgorithms::RegionGrow::
53 _GD1( _TInputImage* image )
54 {
55   typedef
56     itk::Image< _TOutputPixel, _TInputImage::ImageDimension >
57     _TOutputImage;
58   typedef fpa::Image::RegionGrow< _TInputImage, _TOutputImage > _TFilter;
59   typedef typename _TFilter::TGrowFunction                      _TGrow;
60
61   auto filter = this->_CreateITK< _TFilter >( );
62   this->_ConfigureFilter( filter, image );
63   filter->SetGrowFunction( this->GetInputData< _TGrow >( "GrowFunction" ) );
64   filter->SetInsideValue( this->m_Parameters.GetInt( "InsideValue" ) );
65   filter->SetOutsideValue( this->m_Parameters.GetInt( "OutsideValue" ) );
66   filter->Update( );
67   this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
68 }
69
70 // eof - $RCSfile$