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->_MakeOutput< cpPlugins::Interface::Image >( "Output" );
14 this->m_Parameters->ConfigureAsReal( "LowerThresholdValue", 0 );
15 this->m_Parameters->ConfigureAsReal( "UpperThresholdValue", 10000 );
16 this->m_Parameters->ConfigureAsUint( "InsideValue", 1 );
17 this->m_Parameters->ConfigureAsUint( "OutsideValue", 0 );
20 // -------------------------------------------------------------------------
21 cpPlugins::BasicFilters::BinaryThresholdImageFilter::
22 ~BinaryThresholdImageFilter( )
26 // -------------------------------------------------------------------------
27 std::string cpPlugins::BasicFilters::BinaryThresholdImageFilter::
30 cpPlugins::Interface::Image* image =
31 this->GetInput< cpPlugins::Interface::Image >( "Input" );
33 return( "BinaryThresholdImageFilter: No input image." );
35 itk::DataObject* itk_image = NULL;
37 cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 );
38 else cpPlugins_Image_Demangle_AllScalarTypes( 3, image, itk_image, r, _GD0 );
39 else cpPlugins_Image_Demangle_AllScalarTypes( 4, image, itk_image, r, _GD0 );
40 else r = "BinaryThresholdImageFilter: Input image type not supported.";
44 // -------------------------------------------------------------------------
46 std::string cpPlugins::BasicFilters::BinaryThresholdImageFilter::
47 _GD0( itk::DataObject* image )
50 this->_RealGD< I, itk::Image< unsigned char, I::ImageDimension > >(
56 // -------------------------------------------------------------------------
57 template< class I, class O >
58 inline std::string cpPlugins::BasicFilters::BinaryThresholdImageFilter::
59 _RealGD( itk::DataObject* image )
61 typedef itk::BinaryThresholdImageFilter< I, O > _F;
62 typedef typename I::PixelType _IP;
63 typedef typename O::PixelType _OP;
67 // this->m_Parameters.GetValueAsUint( "NumberOfHistogramBins" );
68 _IP lower_val = _IP( this->m_Parameters->GetReal( "LowerThresholdValue" ) );
69 _IP upper_val = _IP( this->m_Parameters->GetReal( "UpperThresholdValue" ) );
70 _OP in_val = _OP( this->m_Parameters->GetUint( "InsideValue" ) );
71 _OP out_val = _OP( this->m_Parameters->GetUint( "OutsideValue" ) );
74 _F* filter = this->_CreateITK< _F >( );
75 filter->SetInput( dynamic_cast< I* >( image ) );
76 filter->SetLowerThreshold( lower_val );
77 filter->SetUpperThreshold( upper_val );
78 filter->SetInsideValue( in_val );
79 filter->SetOutsideValue( out_val );
83 cpPlugins::Interface::Image* out =
84 this->GetOutput< cpPlugins::Interface::Image >( "Output" );
87 out->SetITK< O >( filter->GetOutput( ) );
91 return( "BinaryThresholdImageFilter: output not correctly created." );