]> Creatis software - FrontAlgorithms.git/blob - plugins/fpa/RegionGrowThresholdFunction.cxx
1c27fe57023d2b650a052676a3b3ad39ccf7b91b
[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 std::string fpaPlugins::RegionGrowThresholdFunction::
29 _GenerateData( )
30 {
31   auto image =
32     this->GetInputData( "ReferenceImage" )->GetITK< itk::DataObject >( );
33   std::string   cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 2 );
34   if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 3 );
35   return( r );
36 }
37
38 // -------------------------------------------------------------------------
39 template< class _TImage >
40 std::string fpaPlugins::RegionGrowThresholdFunction::
41 _GD0( _TImage* image )
42 {
43   typedef
44     fpa::Image::Functors::RegionGrowThresholdFunction< _TImage >
45     _TFunctor;
46
47   if( image == NULL )
48     return( "fpaPlugins::RegionGrowThresholdFunction: invalid image type." );
49
50   auto out = this->GetOutputData( "Output" );
51   auto f = out->GetITK< _TFunctor >( );
52   if( f == NULL )
53   {
54     typename _TFunctor::Pointer ptr_f = _TFunctor::New( );
55     f = ptr_f.GetPointer( );
56     out->SetITK( f );
57
58   } // fi
59   f->SetLowerThreshold( this->m_Parameters.GetReal( "LowerThreshold" ) );
60   f->SetUpperThreshold( this->m_Parameters.GetReal( "UpperThreshold" ) );
61   return( "" );
62 }
63
64 // eof - $RCSfile$