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