1 #include "BinaryThreshold.h"
3 #include <cpInstances/DataObjects/Image.h>
6 #include <fpa/Image/Functors/RegionGrow/BinaryThreshold.h>
8 // -------------------------------------------------------------------------
9 void fpaPlugins_ImageFunctors::BinaryThreshold::
10 Instantiate( itk::LightObject* filter )
12 auto itk_filter = dynamic_cast< itk::ProcessObject* >( filter );
13 if( itk_filter != NULL )
15 auto inputs = itk_filter->GetInputs( );
16 if( inputs.size( ) > 0 )
18 cpPlugins_Demangle_Image_ScalarPixels_AllDims_2(
19 inputs[ 0 ].GetPointer( ), _GD0, itk_filter
21 this->_Error( "Invalid input data." );
24 this->_Error( "Not enough inputs." );
27 this->_Error( "Invalid instantiation filter." );
30 // -------------------------------------------------------------------------
31 fpaPlugins_ImageFunctors::BinaryThreshold::
35 this->_ConfigureOutput< cpPlugins::Pipeline::DataObject >( "Functor" );
36 this->GetOutput( "Functor" )->SetITK( this );
37 this->m_Parameters.ConfigureAsReal( "Lower", 0 );
38 this->m_Parameters.ConfigureAsReal( "Upper", 1 );
41 // -------------------------------------------------------------------------
42 fpaPlugins_ImageFunctors::BinaryThreshold::
47 // -------------------------------------------------------------------------
48 void fpaPlugins_ImageFunctors::BinaryThreshold::
53 // -------------------------------------------------------------------------
54 template< class _TInput >
55 void fpaPlugins_ImageFunctors::BinaryThreshold::
56 _GD0( _TInput* input, itk::ProcessObject* filter )
58 auto outputs = filter->GetOutputs( );
59 if( outputs.size( ) > 0 )
61 cpPlugins_Demangle_Image_IntPixels_3(
62 outputs[ 0 ].GetPointer( ), _GD1, _TInput::ImageDimension, input, filter
64 this->_Error( "Invalid output data." );
67 this->_Error( "Not enough outputs." );
70 // -------------------------------------------------------------------------
71 template< class _TInput, class _TOutput >
72 void fpaPlugins_ImageFunctors::BinaryThreshold::
73 _GD1( _TOutput* output, _TInput* input, itk::ProcessObject* filter )
75 typedef typename _TOutput::PixelType _TValue;
76 typedef fpa::Image::Functors::RegionGrow::BinaryThreshold< _TInput, _TValue > _TFunctor;
78 auto f = dynamic_cast< _TFunctor* >( this->m_Functor.GetPointer( ) );
81 typename _TFunctor::Pointer ptr_f = _TFunctor::New( );
82 f = ptr_f.GetPointer( );
86 f->SetLower( this->m_Parameters.GetReal( "Lower" ) );
87 f->SetUpper( this->m_Parameters.GetReal( "Upper" ) );