]> 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 =
32     this->GetInputData( "ReferenceImage" )->GetITK< itk::DataObject >( );
33   cpPlugins_Image_Demangle_Pixel_AllScalars     ( _GD0, image, 2 );
34   else cpPlugins_Image_Demangle_Pixel_AllScalars( _GD0, image, 3 );
35   else this->_Error( "No valid input image." );
36 }
37
38 // -------------------------------------------------------------------------
39 template< class _TImage >
40 void fpaPlugins::RegionGrowThresholdFunction::
41 _GD0( _TImage* image )
42 {
43   typedef
44     fpa::Image::Functors::RegionGrowThresholdFunction< _TImage >
45     _TFunctor;
46
47   auto out = this->GetOutputData( "Output" );
48   auto f = out->GetITK< _TFunctor >( );
49   if( f == NULL )
50   {
51     typename _TFunctor::Pointer ptr_f = _TFunctor::New( );
52     f = ptr_f.GetPointer( );
53     out->SetITK( f );
54
55   } // fi
56   f->SetLowerThreshold( this->m_Parameters.GetReal( "LowerThreshold" ) );
57   f->SetUpperThreshold( this->m_Parameters.GetReal( "UpperThreshold" ) );
58 }
59
60 // eof - $RCSfile$