From 72853b99e3ec514e82859f47b390be4dc2958d0b Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Wed, 30 Sep 2015 18:13:18 -0500 Subject: [PATCH] Coding style improved. --- .../BinaryThresholdImageFilter.cxx | 35 +++++++------------ .../BasicFilters/BinaryThresholdImageFilter.h | 7 ++-- .../BasicFilters/MedianImageFilter.cxx | 20 +++++------ .../Plugins/BasicFilters/MedianImageFilter.h | 7 ++-- 4 files changed, 32 insertions(+), 37 deletions(-) diff --git a/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.cxx index d3d541e..ea7c965 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.cxx @@ -15,25 +15,16 @@ BinaryThresholdImageFilter( ) this->_MakeOutput< cpPlugins::Interface::Image >( 0 ); 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.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.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; } @@ -85,13 +76,14 @@ 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")); + _IP lower_val = _IP( this->m_Parameters.GetValueAsReal( "LowerValue" ) ); + _IP upper_val = _IP( this->m_Parameters.GetValueAsReal( "UpperValue" ) ); _OP in_val = _OP( this->m_Parameters.GetValueAsReal( "InsideValue" ) ); _OP out_val = _OP( this->m_Parameters.GetValueAsReal( "OutsideValue" ) ); @@ -104,9 +96,8 @@ _RealGD( itk::DataObject* image ) } // fi 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( ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.h b/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.h index b410151..74a970f 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.h +++ b/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.h @@ -14,14 +14,17 @@ namespace cpPlugins : public cpPlugins::Interface::ImageToImageFilter { public: - typedef BinaryThresholdImageFilter Self; + typedef BinaryThresholdImageFilter Self; typedef cpPlugins::Interface::ImageToImageFilter Superclass; typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; public: itkNewMacro( Self ); - itkTypeMacro( BinaryThresholdImageFilter, cpPluginsInterfaceImageToImageFilter ); + itkTypeMacro( + BinaryThresholdImageFilter, + cpPluginsInterfaceImageToImageFilter + ); protected: BinaryThresholdImageFilter( ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.cxx index 53a9d28..d806506 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.cxx @@ -15,10 +15,10 @@ MedianImageFilter( ) this->_MakeOutput< cpPlugins::Interface::Image >( 0 ); using namespace cpPlugins::Interface; - this->m_DefaultParameters.Configure(Parameters::Real, "Radius"); - - this->m_DefaultParameters.SetValueAsReal("Radius", 3); - + this->m_DefaultParameters.Configure( Parameters::Uint, "Radius" ); + + this->m_DefaultParameters.SetValueAsUint( "Radius", 3 ); + this->m_Parameters = this->m_DefaultParameters; } @@ -70,12 +70,11 @@ inline std::string cpPlugins::BasicFilters::MedianImageFilter:: _RealGD( itk::DataObject* image ) { typedef itk::MedianImageFilter< I, O > _F; - typedef typename O::PixelType _OP; + typedef typename _F::RadiusType _RT; // Get parameters - - _OP rad_val = _OP(this->m_Parameters.GetValueAsReal("Radius")); - + _RT rad_val; + rad_val.Fill( this->m_Parameters.GetValueAsUint( "Radius" ) ); // Configure filter _F* filter = dynamic_cast< _F* >( this->m_RealProcessObject.GetPointer( ) ); @@ -86,9 +85,8 @@ _RealGD( itk::DataObject* image ) } // fi filter->SetInput( dynamic_cast< I* >( image ) ); - - filter->SetRadius(rad_val); - + filter->SetRadius( rad_val ); + filter->Update( ); // Connect output diff --git a/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.h b/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.h index a4d4679..8b3cbf7 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.h +++ b/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.h @@ -14,14 +14,17 @@ namespace cpPlugins : public cpPlugins::Interface::ImageToImageFilter { public: - typedef MedianImageFilter Self; + typedef MedianImageFilter Self; typedef cpPlugins::Interface::ImageToImageFilter Superclass; typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; public: itkNewMacro( Self ); - itkTypeMacro( MedianImageFilter, cpPluginsInterfaceImageToImageFilter ); + itkTypeMacro( + MedianImageFilter, + cpPluginsInterfaceImageToImageFilter + ); protected: MedianImageFilter( ); -- 2.47.1