X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FPlugins%2FBasicFilters%2FOtsuThresholdImageFilter.cxx;h=5c419ae4e1bf6e61930742365e10332ee79c1e27;hb=6ffc11d77924d6ab7e94db95d41105982ac73e00;hp=8e2f6fbb59fdcea2c81e4c69a6508998ff13d725;hpb=3633aade338a13bc83642e99e6d61b6499e4b3af;p=cpPlugins.git diff --git a/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx index 8e2f6fb..5c419ae 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx @@ -9,11 +9,15 @@ OtsuThresholdImageFilter( ) : Superclass( ) { this->_AddInput( "Input" ); - this->_MakeOutput< cpPlugins::Interface::Image >( "Output" ); + this->_AddOutput< cpPlugins::Interface::Image >( "Output" ); - this->m_Parameters->ConfigureAsUint( "NumberOfHistogramBins", 100 ); - this->m_Parameters->ConfigureAsUint( "InsideValue", 255 ); - this->m_Parameters->ConfigureAsUint( "OutsideValue", 0 ); + this->m_Parameters->ConfigureAsUint( "NumberOfHistogramBins" ); + this->m_Parameters->ConfigureAsUint( "InsideValue" ); + this->m_Parameters->ConfigureAsUint( "OutsideValue" ); + + this->m_Parameters->SetUint( "NumberOfHistogramBins", 100 ); + this->m_Parameters->SetUint( "InsideValue", 255 ); + this->m_Parameters->SetUint( "OutsideValue", 0 ); } // ------------------------------------------------------------------------- @@ -26,11 +30,7 @@ cpPlugins::BasicFilters::OtsuThresholdImageFilter:: std::string cpPlugins::BasicFilters::OtsuThresholdImageFilter:: _GenerateData( ) { - cpPlugins::Interface::Image* image = - this->GetInput< cpPlugins::Interface::Image >( "Input" ); - if( image == NULL ) - return( "OtsuThresholdImageFilter: No input image." ); - + auto image = this->GetInputData< cpPlugins::Interface::Image >( "Input" ); itk::DataObject* itk_image = NULL; std::string r = ""; cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 ); @@ -69,20 +69,14 @@ _RealGD( itk::DataObject* image ) _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 >( "Output" ); - if( out != NULL ) - { - out->SetITK< O >( filter->GetOutput( ) ); - return( "" ); - } - else - return( "OtsuThresholdImageFilter: output not correctly created." ); + auto out = this->GetOutputData< cpPlugins::Interface::Image >( "Output" ); + out->SetITK( filter->GetOutput( ) ); + return( "" ); } // eof - $RCSfile$