]> Creatis software - FrontAlgorithms.git/blob - plugins/fpa/ImageRegionGrow.cxx
...
[FrontAlgorithms.git] / plugins / fpa / ImageRegionGrow.cxx
1 #include "ImageRegionGrow.h"
2
3 #include <cpPlugins/Image.h>
4 #include <fpa_Instances/Filters.h>
5
6 // -------------------------------------------------------------------------
7 fpaPlugins::ImageRegionGrow::
8 ImageRegionGrow( )
9   : Superclass( )
10 {
11   this->_AddInput( "GrowFunctor", false );
12   this->m_Parameters.ConfigureAsUint( "InsideValue" );
13   this->m_Parameters.ConfigureAsUint( "OutsideValue" );
14   this->m_Parameters.SetUint( "InsideValue", 1 );
15   this->m_Parameters.SetUint( "OutsideValue", 0 );
16 }
17
18 // -------------------------------------------------------------------------
19 fpaPlugins::ImageRegionGrow::
20 ~ImageRegionGrow( )
21 {
22 }
23
24 // -------------------------------------------------------------------------
25 void fpaPlugins::ImageRegionGrow::
26 _GenerateData( )
27 {
28   auto image = this->GetInputData< itk::DataObject >( "Input" );
29   cpPlugins_Image_Demangle_Pixel_AllScalars     ( _GD0, image, 2 );
30   else cpPlugins_Image_Demangle_Pixel_AllScalars( _GD0, image, 3 );
31   else this->_Error( "No valid input image." );
32 }
33
34 // -------------------------------------------------------------------------
35 template< class _TImage >
36 void fpaPlugins::ImageRegionGrow::
37 _GD0( _TImage* image )
38 {
39   typedef unsigned short _TPixel;
40   typedef itk::Image< _TPixel, _TImage::ImageDimension > _TOutImage;
41   typedef fpa::Image::RegionGrow< _TImage, _TOutImage >  _TFilter;
42   typedef typename _TFilter::TGrowingFunction            _TGrowFunctor;
43   typedef typename _TFilter::TResult                     _TResult;
44
45   // Create filter
46   _TFilter* filter = this->_ConfigureFilter< _TFilter >( );
47
48   typename _TGrowFunctor::Pointer functor;
49   auto wrap_functor = this->GetInput( "GrowFunctor" );
50   if( wrap_functor != NULL )
51     functor = wrap_functor->GetITK< _TGrowFunctor >( );
52   if( functor.IsNull( ) )
53     filter->SetGrowingFunction( functor );
54   filter->SetInsideValue(
55     _TResult( this->m_Parameters.GetUint( "InsideValue" ) )
56     );
57   filter->SetOutsideValue(
58     _TResult( this->m_Parameters.GetUint( "OutsideValue" ) )
59     );
60
61   // Go!!!
62   this->_ExecuteFilter( filter );
63 }
64
65 // eof - $RCSfile$