Commit e54a9d6f authored by Mathias Goldau's avatar Mathias Goldau
Browse files

[CHANGE #237] Improved scalar segmentation module to use a slider, this made...

[CHANGE #237] Improved scalar segmentation module to use a slider, this made bug tracking for #237 much easier
parent 53d25a4f
......@@ -38,6 +38,8 @@ WSegmentationAlgoThreshold::~WSegmentationAlgoThreshold()
void WSegmentationAlgoThreshold::properties()
{
m_threshold = m_properties->addProperty( "Threshold", "Threshold in %.", 0.0, m_propCondition );
m_threshold->setMin( 0.0 );
m_threshold->setMax( 1.0 );
}
std::string WSegmentationAlgoThreshold::getName()
......
......@@ -96,14 +96,12 @@ private:
template< typename T >
WSegmentationAlgo::DataSetPtr WSegmentationAlgoThreshold::operator() ( WValueSet< T > const* valueset ) const
{
double thres = m_threshold->get( true );
boost::shared_ptr< std::vector< T > > values = boost::shared_ptr< std::vector< T > >( new std::vector< T >( valueset->size() ) );
double threshold = valueset->getMinimumValue() + m_threshold->get( true ) * ( valueset->getMaximumValue() - valueset->getMinimumValue() );
for( std::size_t k = 0; k < valueset->size(); ++k )
{
( *values )[k] = ( static_cast< double >( valueset->getScalar( k ) ) <
thres * ( valueset->getMaximumValue() - valueset->getMinimumValue() ) / 100.0 + valueset->getMinimumValue()
? static_cast< T >( 0 ) : static_cast< T >( 100 ) );
( *values )[k] = static_cast< T >( static_cast< double >( valueset->getScalar( k ) ) < threshold ? 0 : 1 );
}
boost::shared_ptr< WValueSet< T > > vs( new WValueSet< T >( 0, 1, values, DataType< T >::type ) );
return DataSetPtr( new WDataSetScalar( vs, m_dataSet->getGrid() ) );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment