From 9ddfa27c59f7a0cdea8758b8aff1d9cd80c60d99 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leonardo=20Fl=C3=B3rez-Valencia?= Date: Fri, 18 Aug 2017 11:49:40 -0500 Subject: [PATCH] ... --- appli/CTBronchi/MoriLabelling.h | 17 ++++++----------- appli/CTBronchi/MoriLabelling.hxx | 13 ++++++------- appli/CTBronchi/Process.cxx | 30 +++++++++++++++++++++++++----- 3 files changed, 37 insertions(+), 23 deletions(-) diff --git a/appli/CTBronchi/MoriLabelling.h b/appli/CTBronchi/MoriLabelling.h index caa96aa..d4eea09 100644 --- a/appli/CTBronchi/MoriLabelling.h +++ b/appli/CTBronchi/MoriLabelling.h @@ -2,7 +2,6 @@ // @author Leonardo Florez Valencia // @email florez-l@javeriana.edu.co // ========================================================================= - #ifndef __CTBronchi__MoriLabelling__h__ #define __CTBronchi__MoriLabelling__h__ @@ -13,15 +12,6 @@ #include #include -/* TODO - #include - #include - #include - #include - #include - #include -*/ - namespace CTBronchi { /** @@ -53,7 +43,8 @@ namespace CTBronchi typedef CTBronchi::MoriLabellingTraits< TInputImage, TLabelImage > TTraits; fpaTraitsMacro( typename, TTraits ); - typedef fpa::Filters::Image::Algorithm< fpa::Filters::RegionGrow< TTraits > > TAlgorithm; + typedef fpa::Filters::RegionGrow< TTraits > TBase; + typedef fpa::Filters::Image::Algorithm< TBase > TAlgorithm; typedef fpa::Filters::Image::LabelsSeedFilter< TAlgorithm, _TLabelImage > Superclass; typedef MoriLabelling Self; typedef itk::SmartPointer< Self > Pointer; @@ -65,6 +56,9 @@ namespace CTBronchi itkNewMacro( Self ); itkTypeMacro( CTBronchi::MoriLabelling, fpa::Filters::Image::RegionGrow ); + itkGetConstMacro( InputInsideValue, TInputValue ); + itkSetMacro( InputInsideValue, TInputValue ); + public: TInputValue GetUpperThreshold( ) const; void SetUpperThreshold( TInputValue t ); @@ -82,6 +76,7 @@ namespace CTBronchi protected: typename TLabelFunctor::Pointer m_LabelFunctor; + TInputValue m_InputInsideValue; }; } // ecapseman diff --git a/appli/CTBronchi/MoriLabelling.hxx b/appli/CTBronchi/MoriLabelling.hxx index e654b09..7963416 100644 --- a/appli/CTBronchi/MoriLabelling.hxx +++ b/appli/CTBronchi/MoriLabelling.hxx @@ -45,18 +45,17 @@ template< class _TInputImage, class _TLabelImage > void CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >:: _UpdateOutputValue( TNode& n ) { - this->Superclass::_UpdateOutputValue( n ); + this->TBase::_UpdateOutputValue( n ); if( n.FrontId != 0 ) { const TLabelImage* input_labels = this->GetInputLabels( ); - if( input_labels->GetPixel( n.Vertex ) == this->GetInsideValue( ) ) - n.Value = TOutputValue( 1 ); // this->GetInsideLabel( ); - else + if( input_labels->GetPixel( n.Vertex ) != this->GetInputInsideValue( ) ) n.Value = TOutputValue( 0 ); - /* TODO - if( input_labels->GetPixel( n.Vertex ) == this->GetInsideValue( ) ) - */ + else + n.Value = this->GetInsideValue( ); + } // fi + this->GetOutput( )->SetPixel( n.Vertex, n.Value ); } #endif // __CTBronchi__MoriLabelling__hxx__ diff --git a/appli/CTBronchi/Process.cxx b/appli/CTBronchi/Process.cxx index 848a1f0..e169148 100644 --- a/appli/CTBronchi/Process.cxx +++ b/appli/CTBronchi/Process.cxx @@ -14,21 +14,27 @@ #include #include #include +#include +#include #include // ------------------------------------------------------------------------- const unsigned int Dim = 3; typedef short TInputPixel; typedef unsigned char TLabelPixel; +typedef float TScalar; typedef itk::Image< TInputPixel, Dim > TInputImage; typedef itk::Image< TLabelPixel, Dim > TLabelImage; +typedef itk::Image< TScalar, Dim > TScalarImage; typedef std::map< std::string, std::string > TMap; // ------------------------------------------------------------------------- TMap Args; TInputImage::PointType global_seed; -TLabelPixel inside_value = std::numeric_limits< TLabelPixel >::max( ); +TLabelPixel inside_value = TLabelPixel( 1 ); TLabelPixel outside_value = TLabelPixel( 0 ); +TLabelPixel inside_label = TLabelPixel( 1 ); +TLabelPixel outside_label = TLabelPixel( 2 ); // ------------------------------------------------------------------------- double MeasureTime( itk::ProcessObject* f ) @@ -142,9 +148,12 @@ void Label( _TOutputPtr& output, const _TInputPtr& input, const _TOutputPtr& lab typename _TLabelling::Pointer labelling = _TLabelling::New( ); labelling->SetInput( input ); labelling->SetInputLabels( labels ); - // TODO: labelling->SetOutsideValue( ); // out label - // TODO: labelling->SetInsideValue( ); // inside label - // TODO: labelling->SetUpperThreshold( ); + labelling->SetOutsideValue( outside_label ); + labelling->SetInsideValue( inside_label ); + labelling->SetInputInsideValue( inside_value ); + labelling->SetUpperThreshold( + TInputPixel( std::atof( Args[ "labelling_upper_threshold" ].c_str( ) ) ) + ); double t = MeasureTime( labelling ); std::cout << "Labelling executed in " << t << " s" << std::endl; output = labelling->GetOutput( ); @@ -154,6 +163,14 @@ void Label( _TOutputPtr& output, const _TInputPtr& input, const _TOutputPtr& lab output->DisconnectPipeline( ); } +// ------------------------------------------------------------------------- +template< class _TRawPtr, class _TLabelPtr > +void RandomWalker( _TLabelPtr& output, const _TRawPtr& raw, const _TLabelPtr& labels ) +{ + typedef typename _TRawPtr::ObjectType _TRaw; + typedef typename _TLabelPtr::ObjectType _TLabel; +} + // ------------------------------------------------------------------------- bool ParseArgs( int argc, char* argv[] ) { @@ -171,6 +188,8 @@ bool ParseArgs( int argc, char* argv[] ) Args[ "mori_lower_threshold" ] = "-1024"; Args[ "mori_upper_threshold" ] = "0"; Args[ "mori_delta_threshold" ] = "1"; + Args[ "labelling_upper_threshold" ] = "-400"; + for( int i = 1; i < argc; i += 2 ) Args[ argv[ i ] + 1 ] = argv[ i + 1 ]; @@ -194,7 +213,8 @@ bool ParseArgs( int argc, char* argv[] ) << "\t[-mori_signal_influence value]" << std::endl << "\t[-mori_lower_threshold value]" << std::endl << "\t[-mori_upper_threshold value]" << std::endl - << "\t[-mori_delta_threshold value]" << std::endl; + << "\t[-mori_delta_threshold value]" << std::endl + << "\t[-labelling_upper_threshold value]" << std::endl; return( false ); } // fi -- 2.45.0