1 #include "BinaryThresholdImageFilter.h"
2 #include <cpPlugins/Interface/Image.h>
4 #include <itkBinaryThresholdImageFilter.h>
6 // -------------------------------------------------------------------------
7 cpPlugins::BasicFilters::BinaryThresholdImageFilter::
8 BinaryThresholdImageFilter( )
11 this->_AddInput( "Input" );
12 this->_AddOutput< cpPlugins::Interface::Image >( "Output" );
14 this->m_Parameters->ConfigureAsReal( "LowerThresholdValue" );
15 this->m_Parameters->ConfigureAsReal( "UpperThresholdValue" );
16 this->m_Parameters->ConfigureAsUint( "InsideValue" );
17 this->m_Parameters->ConfigureAsUint( "OutsideValue" );
19 this->m_Parameters->SetReal( "LowerThresholdValue", 0 );
20 this->m_Parameters->SetReal( "UpperThresholdValue", 10000 );
21 this->m_Parameters->SetUint( "InsideValue", 1 );
22 this->m_Parameters->SetUint( "OutsideValue", 0 );
25 // -------------------------------------------------------------------------
26 cpPlugins::BasicFilters::BinaryThresholdImageFilter::
27 ~BinaryThresholdImageFilter( )
31 // -------------------------------------------------------------------------
32 std::string cpPlugins::BasicFilters::BinaryThresholdImageFilter::
35 cpPlugins::Interface::Image* image =
36 this->GetInput< cpPlugins::Interface::Image >( "Input" );
38 return( "BinaryThresholdImageFilter: No input image." );
40 itk::DataObject* itk_image = NULL;
42 cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 );
43 else cpPlugins_Image_Demangle_AllScalarTypes( 3, image, itk_image, r, _GD0 );
44 else cpPlugins_Image_Demangle_AllScalarTypes( 4, image, itk_image, r, _GD0 );
45 else r = "BinaryThresholdImageFilter: Input image type not supported.";
49 // -------------------------------------------------------------------------
51 std::string cpPlugins::BasicFilters::BinaryThresholdImageFilter::
52 _GD0( itk::DataObject* image )
55 this->_RealGD< I, itk::Image< unsigned char, I::ImageDimension > >(
61 // -------------------------------------------------------------------------
62 template< class I, class O >
63 inline std::string cpPlugins::BasicFilters::BinaryThresholdImageFilter::
64 _RealGD( itk::DataObject* image )
66 typedef itk::BinaryThresholdImageFilter< I, O > _F;
67 typedef typename I::PixelType _IP;
68 typedef typename O::PixelType _OP;
72 // this->m_Parameters.GetValueAsUint( "NumberOfHistogramBins" );
73 _IP lower_val = _IP( this->m_Parameters->GetReal( "LowerThresholdValue" ) );
74 _IP upper_val = _IP( this->m_Parameters->GetReal( "UpperThresholdValue" ) );
75 _OP in_val = _OP( this->m_Parameters->GetUint( "InsideValue" ) );
76 _OP out_val = _OP( this->m_Parameters->GetUint( "OutsideValue" ) );
79 _F* filter = this->_CreateITK< _F >( );
80 filter->SetInput( dynamic_cast< I* >( image ) );
81 filter->SetLowerThreshold( lower_val );
82 filter->SetUpperThreshold( upper_val );
83 filter->SetInsideValue( in_val );
84 filter->SetOutsideValue( out_val );
88 cpPlugins::Interface::Image* out =
89 this->GetOutput< cpPlugins::Interface::Image >( "Output" );
92 out->SetITK< O >( filter->GetOutput( ) );
96 return( "BinaryThresholdImageFilter: output not correctly created." );