X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FPlugins%2FBasicFilters%2FOtsuThresholdImageFilter.cxx;h=22df71acbe944439fc457bb9587ca9dc0fd55f17;hb=d6f15d4cb764982e2b09060a9c0f38636891590c;hp=6e0d36fa29b72d8ee354129fbf3c45f82df53f0d;hpb=b23970017af98ef6617ddf40f225d4d15fa65854;p=cpPlugins.git diff --git a/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx index 6e0d36f..22df71a 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx @@ -8,22 +8,12 @@ cpPlugins::BasicFilters::OtsuThresholdImageFilter:: OtsuThresholdImageFilter( ) : Superclass( ) { - this->m_ClassName = "cpPlugins::BasicFilters::OtsuThresholdImageFilter"; - 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::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->ConfigureAsUint( "NumberOfHistogramBins", 100 ); + this->m_Parameters->ConfigureAsUint( "InsideValue", 255 ); + this->m_Parameters->ConfigureAsUint( "OutsideValue", 0 ); } // ------------------------------------------------------------------------- @@ -37,21 +27,15 @@ std::string cpPlugins::BasicFilters::OtsuThresholdImageFilter:: _GenerateData( ) { cpPlugins::Interface::Image* image = - this->GetInput< cpPlugins::Interface::Image >( 0 ); + this->GetInput< cpPlugins::Interface::Image >( "Input" ); if( image == NULL ) return( "OtsuThresholdImageFilter: 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 = "OtsuThresholdImageFilter: Input image type not supported."; return( r ); } @@ -59,7 +43,7 @@ _GenerateData( ) // ------------------------------------------------------------------------- template< class I > std::string cpPlugins::BasicFilters::OtsuThresholdImageFilter:: -_DemangleOutput( itk::DataObject* image ) +_GD0( itk::DataObject* image ) { return( this->_RealGD< I, itk::Image< unsigned char, I::ImageDimension > >( @@ -77,31 +61,24 @@ _RealGD( itk::DataObject* image ) typedef typename O::PixelType _OP; // Get parameters - unsigned int bins = - this->m_Parameters.GetValueAsUint( "NumberOfHistogramBins" ); - _OP in_val = _OP( this->m_Parameters.GetValueAsReal( "InsideValue" ) ); - _OP out_val = _OP( this->m_Parameters.GetValueAsReal( "OutsideValue" ) ); + unsigned int bins = this->m_Parameters->GetUint( "NumberOfHistogramBins" ); + _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->SetInsideValue( in_val ); - filter->SetOutsideValue( out_val ); + filter->SetInsideValue( out_val ); // WARNING: these are inverted + filter->SetOutsideValue( in_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