X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FPlugins%2FBasicFilters%2FBinaryThresholdImageFilter.cxx;h=5dc60cba906aabf2a6f0a21845275b37b9a22633;hb=0bb74f9a32de4ce1559973ebf72fda495aa2c587;hp=d3d541e8527652d7bafebc8623b9c42ea650e246;hpb=c3c3da5217b6eb255db9c0424f22d4e01250901e;p=cpPlugins.git diff --git a/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.cxx index d3d541e..5dc60cb 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.cxx @@ -8,33 +8,13 @@ cpPlugins::BasicFilters::BinaryThresholdImageFilter:: BinaryThresholdImageFilter( ) : Superclass( ) { - this->m_ClassName = "cpPlugins::BasicFilters::BinaryThresholdImageFilter"; - this->m_ClassCategory = "ImageToImageFilter"; - this->SetNumberOfInputs( 1 ); - this->SetNumberOfOutputs( 1 ); - this->_MakeOutput< cpPlugins::Interface::Image >( 0 ); + this->_AddInput( "Input" ); + this->_MakeOutput< cpPlugins::Interface::Image >( "Output" ); - using namespace cpPlugins::Interface; - this->m_DefaultParameters.Configure(Parameters::Real, "LowerThresholdValue"); - this->m_DefaultParameters.Configure(Parameters::Real, "UpperThresholdValue"); - this->m_DefaultParameters.Configure(Parameters::Real, "InsideValue"); - this->m_DefaultParameters.Configure(Parameters::Real, "OutsideValue"); - - this->m_DefaultParameters.SetValueAsReal("LowerThresholdValue", 100); - this->m_DefaultParameters.SetValueAsReal("UpperThresholdValue",500); - this->m_DefaultParameters.SetValueAsReal("InsideValue", 255); - this->m_DefaultParameters.SetValueAsReal("OutsideValue", 0); - - //this->m_DefaultParameters.Configure( - - // Parameters::Uint, "NumberOfHistogramBins" - // ); - //this->m_DefaultParameters.Configure( Parameters::Real, "InsideValue" ); - //this->m_DefaultParameters.Configure( Parameters::Real, "OutsideValue" ); - //this->m_DefaultParameters.SetValueAsUint( "NumberOfHistogramBins", 100 ); - //this->m_DefaultParameters.SetValueAsReal( "InsideValue", 255 ); - //this->m_DefaultParameters.SetValueAsReal( "OutsideValue", 0 ); - this->m_Parameters = this->m_DefaultParameters; + this->m_Parameters->ConfigureAsReal( "LowerThresholdValue", 0 ); + this->m_Parameters->ConfigureAsReal( "UpperThresholdValue", 10000 ); + this->m_Parameters->ConfigureAsUint( "InsideValue", 1 ); + this->m_Parameters->ConfigureAsUint( "OutsideValue", 0 ); } // ------------------------------------------------------------------------- @@ -48,21 +28,15 @@ std::string cpPlugins::BasicFilters::BinaryThresholdImageFilter:: _GenerateData( ) { cpPlugins::Interface::Image* image = - this->GetInput< cpPlugins::Interface::Image >( 0 ); + this->GetInput< cpPlugins::Interface::Image >( "Input" ); if( image == NULL ) return( "BinaryThresholdImageFilter: No input image." ); itk::DataObject* itk_image = NULL; std::string r = ""; - cpPlugins_Image_Input_Demangle_Dimension_AllScalarTypes( - 2, image, itk_image, r, _DemangleOutput - ); - else cpPlugins_Image_Input_Demangle_Dimension_AllScalarTypes( - 3, image, itk_image, r, _DemangleOutput - ); - else cpPlugins_Image_Input_Demangle_Dimension_AllScalarTypes( - 4, image, itk_image, r, _DemangleOutput - ); + 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 ); } @@ -70,7 +44,7 @@ _GenerateData( ) // ------------------------------------------------------------------------- template< class I > std::string cpPlugins::BasicFilters::BinaryThresholdImageFilter:: -_DemangleOutput( itk::DataObject* image ) +_GD0( itk::DataObject* image ) { return( this->_RealGD< I, itk::Image< unsigned char, I::ImageDimension > >( @@ -85,38 +59,32 @@ 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" ); - _OP lower_val = _OP(this->m_Parameters.GetValueAsReal("LowerValue")); - _OP upper_val = _OP(this->m_Parameters.GetValueAsReal("UpperValue")); - _OP in_val = _OP( this->m_Parameters.GetValueAsReal( "InsideValue" ) ); - _OP out_val = _OP( this->m_Parameters.GetValueAsReal( "OutsideValue" ) ); + _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 = dynamic_cast< _F* >( this->m_RealProcessObject.GetPointer( ) ); - if( filter == NULL ) - { - this->m_RealProcessObject = _F::New( ); - filter = dynamic_cast< _F* >( this->m_RealProcessObject.GetPointer( ) ); - - } // fi + _F* filter = this->_CreateITK< _F >( ); filter->SetInput( dynamic_cast< I* >( image ) ); - //filter->SetNumberOfHistogramBins( bins ); - filter->SetLowerThreshold(lower_val); - filter->SetUpperThreshold(upper_val); + 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 >( 0 ); + this->GetOutput< cpPlugins::Interface::Image >( "Output" ); if( out != NULL ) { - out->SetITKImage< O >( filter->GetOutput( ) ); + out->SetITK< O >( filter->GetOutput( ) ); return( "" ); } else