#ifndef __CTBronchi__MoriLabelling__h__
#define __CTBronchi__MoriLabelling__h__
-#include <itkStatisticsImageFilter.h>
+#include <itkLabelStatisticsImageFilter.h>
#include <fpa/Filters/BaseMarksInterface.h>
#include <fpa/Filters/Image/SeedsFromLabelsInterface.h>
#include <fpa/Filters/Image/DefaultTraits.h>
this->m_Functor->SetUpperThreshold( this->m_UpperThreshold );
- typedef itk::StatisticsImageFilter< _TScalarImage > _TStats;
+ typedef itk::LabelStatisticsImageFilter< _TScalarImage, _TLabels > _TStats;
typename _TStats::Pointer stats = _TStats::New( );
stats->SetInput( this->GetInputVesselness( ) );
+ stats->SetLabelInput( this->GetInputLabels( ) );
stats->Update( );
- double vAvg = double( stats->GetMean( ) );
- double vStd = double( stats->GetSigma( ) );
- double vMin = double( stats->GetMinimum( ) );
- double vMax = double( stats->GetMaximum( ) );
-
- this->m_MinVesselness = vAvg + ( vStd * double( 5 ) );
- /* TODO
- std::cout
- << vAvg << std::endl
- << vStd << std::endl
- << vMin << std::endl
- << vMax << std::endl;
-
- std::cout
- << ( this->m_VesselnessThreshold / double( 100 ) ) * double( vMax )
- << std::endl
- << vAvg + ( vStd * double( 3 ) ) << std::endl;
-
- std::exit( 1 );
- */
- /* TODO
- this->m_MinVesselness =
- ( this->m_VesselnessThreshold / double( 100 ) ) *
- double( stats->GetMaximum( ) );
- */
+
+ typedef typename _TStats::ValidLabelValuesContainerType _TValidLbl;
+ typedef typename _TStats::LabelPixelType _TLabelPx;
+ unsigned long minCount = std::numeric_limits< unsigned long >::max( );
+ double vAvg = 0, vStd = 0;
+ typename _TValidLbl::const_iterator vIt = stats->GetValidLabelValues( ).begin( );
+ for( ; vIt != stats->GetValidLabelValues( ).end( ); ++vIt )
+ {
+ if( stats->HasLabel( *vIt ) )
+ {
+ unsigned long c = stats->GetCount( *vIt );
+ if( c < minCount )
+ {
+ minCount = c;
+ vAvg = stats->GetMean( *vIt );
+ vStd = stats->GetSigma( *vIt );
+
+ } // fi
+
+ } // fi
+
+ } // rof
+ this->m_MinVesselness = vAvg + ( vStd * this->m_VesselnessThreshold );
}
virtual void _PostComputeOutputValue( TNode& n ) override