#include "BinaryThresholdImageFilter.h" #include #include // ------------------------------------------------------------------------- cpPlugins::BasicFilters::BinaryThresholdImageFilter:: BinaryThresholdImageFilter( ) : Superclass( ) { this->_AddInput( "Input" ); this->_MakeOutput< cpPlugins::Interface::Image >( "Output" ); this->m_Parameters->ConfigureAsReal( "LowerThresholdValue" ); this->m_Parameters->ConfigureAsReal( "UpperThresholdValue" ); this->m_Parameters->ConfigureAsUint( "InsideValue" ); this->m_Parameters->ConfigureAsUint( "OutsideValue" ); this->m_Parameters->SetReal( "LowerThresholdValue", 0 ); this->m_Parameters->SetReal( "UpperThresholdValue", 10000 ); this->m_Parameters->SetUint( "InsideValue", 1 ); this->m_Parameters->SetUint( "OutsideValue", 0 ); } // ------------------------------------------------------------------------- cpPlugins::BasicFilters::BinaryThresholdImageFilter:: ~BinaryThresholdImageFilter( ) { } // ------------------------------------------------------------------------- std::string cpPlugins::BasicFilters::BinaryThresholdImageFilter:: _GenerateData( ) { cpPlugins::Interface::Image* image = this->GetInput< cpPlugins::Interface::Image >( "Input" ); if( image == NULL ) return( "BinaryThresholdImageFilter: No input image." ); itk::DataObject* itk_image = NULL; std::string r = ""; cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 ); else cpPlugins_Image_Demangle_AllScalarTypes( 3, image, itk_image, r, _GD0 ); else cpPlugins_Image_Demangle_AllScalarTypes( 4, image, itk_image, r, _GD0 ); else r = "BinaryThresholdImageFilter: Input image type not supported."; return( r ); } // ------------------------------------------------------------------------- template< class I > std::string cpPlugins::BasicFilters::BinaryThresholdImageFilter:: _GD0( itk::DataObject* image ) { return( this->_RealGD< I, itk::Image< unsigned char, I::ImageDimension > >( image ) ); } // ------------------------------------------------------------------------- template< class I, class O > inline std::string cpPlugins::BasicFilters::BinaryThresholdImageFilter:: _RealGD( itk::DataObject* image ) { typedef itk::BinaryThresholdImageFilter< I, O > _F; typedef typename I::PixelType _IP; typedef typename O::PixelType _OP; // Get parameters //unsigned int bins = // this->m_Parameters.GetValueAsUint( "NumberOfHistogramBins" ); _IP lower_val = _IP( this->m_Parameters->GetReal( "LowerThresholdValue" ) ); _IP upper_val = _IP( this->m_Parameters->GetReal( "UpperThresholdValue" ) ); _OP in_val = _OP( this->m_Parameters->GetUint( "InsideValue" ) ); _OP out_val = _OP( this->m_Parameters->GetUint( "OutsideValue" ) ); // Configure filter _F* filter = this->_CreateITK< _F >( ); filter->SetInput( dynamic_cast< I* >( image ) ); filter->SetLowerThreshold( lower_val ); filter->SetUpperThreshold( upper_val ); filter->SetInsideValue( in_val ); filter->SetOutsideValue( out_val ); filter->Update( ); // Connect output cpPlugins::Interface::Image* out = this->GetOutput< cpPlugins::Interface::Image >( "Output" ); if( out != NULL ) { out->SetITK< O >( filter->GetOutput( ) ); return( "" ); } else return( "BinaryThresholdImageFilter: output not correctly created." ); } // eof - $RCSfile$