]> Creatis software - FrontAlgorithms.git/blob - plugins/fpa/RegionGrowThresholdFunction.cxx
...
[FrontAlgorithms.git] / plugins / fpa / RegionGrowThresholdFunction.cxx
1 #include "RegionGrowThresholdFunction.h"
2
3 #include <cpPlugins/Image.h>
4 #include <fpa/Image/Functors/RegionGrowThresholdFunction.h>
5
6 // -------------------------------------------------------------------------
7 fpaPlugins::RegionGrowThresholdFunction::
8 RegionGrowThresholdFunction( )
9   : Superclass( )
10 {
11   this->_AddInput( "ReferenceImage" );
12   this->_AddOutput< cpPlugins::DataObject >( "Output" );
13
14   this->m_Parameters.ConfigureAsReal( "LowerThreshold" );
15   this->m_Parameters.ConfigureAsReal( "UpperThreshold" );
16
17   this->m_Parameters.SetReal( "LowerThreshold", 0 );
18   this->m_Parameters.SetReal( "UpperThreshold", 1 );
19 }
20
21 // -------------------------------------------------------------------------
22 fpaPlugins::RegionGrowThresholdFunction::
23 ~RegionGrowThresholdFunction( )
24 {
25 }
26
27 // -------------------------------------------------------------------------
28 void fpaPlugins::RegionGrowThresholdFunction::
29 _GenerateData( )
30 {
31   auto image = this->GetInputData< itk::DataObject >( "ReferenceImage" );
32   cpPlugins_Image_Demangle_Pixel_AllScalars     ( _GD0, image, 2 );
33   else cpPlugins_Image_Demangle_Pixel_AllScalars( _GD0, image, 3 );
34   else this->_Error( "No valid input image." );
35 }
36
37 // -------------------------------------------------------------------------
38 template< class _TImage >
39 void fpaPlugins::RegionGrowThresholdFunction::
40 _GD0( _TImage* image )
41 {
42   typedef
43     fpa::Image::Functors::RegionGrowThresholdFunction< _TImage >
44     _TFunctor;
45
46   auto out = this->GetOutput( "Output" );
47   auto f = out->GetITK< _TFunctor >( );
48   if( f == NULL )
49   {
50     typename _TFunctor::Pointer ptr_f = _TFunctor::New( );
51     f = ptr_f.GetPointer( );
52     out->SetITK( f );
53
54   } // fi
55   f->SetLowerThreshold( this->m_Parameters.GetReal( "LowerThreshold" ) );
56   f->SetUpperThreshold( this->m_Parameters.GetReal( "UpperThreshold" ) );
57 }
58
59 // eof - $RCSfile$