X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=plugins%2FcpPluginsImageFilters%2FBinaryThresholdImageFilter.cxx;h=6545d56750072111aa70e519d1f482d2d6f039bc;hb=e29096b7c37e89da4cda28bde9102cdb9ff159ea;hp=5915829b93cc0a79e5110c5d35510f913f1c75b2;hpb=1b0022070ff3b5f80f6f8c8b87f73032f5685eaf;p=cpPlugins.git diff --git a/plugins/cpPluginsImageFilters/BinaryThresholdImageFilter.cxx b/plugins/cpPluginsImageFilters/BinaryThresholdImageFilter.cxx index 5915829..6545d56 100644 --- a/plugins/cpPluginsImageFilters/BinaryThresholdImageFilter.cxx +++ b/plugins/cpPluginsImageFilters/BinaryThresholdImageFilter.cxx @@ -1,10 +1,9 @@ #include #include +#include #include #include -#include -#include #include // ------------------------------------------------------------------------- @@ -20,10 +19,24 @@ BinaryThresholdImageFilter( ) this->m_Parameters.ConfigureAsUint( "InsideValue" ); this->m_Parameters.ConfigureAsUint( "OutsideValue" ); + std::vector< std::string > choices; + choices.push_back( "char" ); + choices.push_back( "short" ); + choices.push_back( "int" ); + choices.push_back( "long" ); + choices.push_back( "float" ); + choices.push_back( "double" ); + choices.push_back( "unsigned char" ); + choices.push_back( "unsigned short" ); + choices.push_back( "unsigned int" ); + choices.push_back( "unsigned long" ); + this->m_Parameters.ConfigureAsChoices( "OutputResolution", choices ); + this->m_Parameters.SetReal( "LowerThresholdValue", 0 ); this->m_Parameters.SetReal( "UpperThresholdValue", 10000 ); - this->m_Parameters.SetUint( "InsideValue", 1 ); - this->m_Parameters.SetUint( "OutsideValue", 0 ); + this->m_Parameters.SetReal( "InsideValue", 1 ); + this->m_Parameters.SetReal( "OutsideValue", 0 ); + this->m_Parameters.SetSelectedChoice( "OutputResolution", "unsigned char" ); } // ------------------------------------------------------------------------- @@ -45,16 +58,35 @@ _GenerateData( ) } // ------------------------------------------------------------------------- -template< class I > +template< class _TImage > std::string cpPluginsImageFilters::BinaryThresholdImageFilter:: -_GD0( I* image ) +_GD0( _TImage* image ) { if( image != NULL ) - return( - this->_GD1< I, itk::Image< unsigned char, I::ImageDimension > >( - image - ) - ); + { + auto choice = this->m_Parameters.GetSelectedChoice( "OutputResolution" ); + if( choice == "char" ) + return( this->_GD1< _TImage, char >( image ) ); + else if( choice == "short" ) + return( this->_GD1< _TImage, short >( image ) ); + else if( choice == "int" ) + return( this->_GD1< _TImage, int >( image ) ); + else if( choice == "long" ) + return( this->_GD1< _TImage, long >( image ) ); + else if( choice == "float" ) + return( this->_GD1< _TImage, float >( image ) ); + else if( choice == "double" ) + return( this->_GD1< _TImage, double >( image ) ); + else if( choice == "unsigned char" ) + return( this->_GD1< _TImage, unsigned char >( image ) ); + else if( choice == "unsigned short" ) + return( this->_GD1< _TImage, unsigned short >( image ) ); + else if( choice == "unsigned int" ) + return( this->_GD1< _TImage, unsigned int >( image ) ); + else if( choice == "unsigned long" ) + return( this->_GD1< _TImage, unsigned long >( image ) ); + else return( "BinaryThresholdImageFilter: no valid output type." ); + } else return( "ImageFilters::BinaryThresholdImageFilter: No valid input image." @@ -62,19 +94,20 @@ _GD0( I* image ) } // ------------------------------------------------------------------------- -template< class I, class O > +template< class _TImage, class _TBinaryPixel > std::string cpPluginsImageFilters::BinaryThresholdImageFilter:: -_GD1( I* image ) +_GD1( _TImage* image ) { - typedef itk::BinaryThresholdImageFilter< I, O > _F; - typedef typename I::PixelType _IP; - typedef typename O::PixelType _OP; + typedef itk::Image< _TBinaryPixel, _TImage::ImageDimension > _TBinaryImage; + typedef itk::BinaryThresholdImageFilter< _TImage, _TBinaryImage > _F; + typedef typename _TImage::PixelType _TP; + typedef typename _TBinaryImage::PixelType _UP; // Get parameters - _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" ) ); + _TP lower_val = _TP( this->m_Parameters.GetReal( "LowerThresholdValue" ) ); + _TP upper_val = _TP( this->m_Parameters.GetReal( "UpperThresholdValue" ) ); + _UP in_val = _UP( this->m_Parameters.GetReal( "InsideValue" ) ); + _UP out_val = _UP( this->m_Parameters.GetReal( "OutsideValue" ) ); // Configure filter _F* filter = this->_CreateITK< _F >( );