From 6c0b77c2a8e3b821ccbe9c72c705fcd561bb90c2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leonardo=20Fl=C3=B3rez-Valencia?= Date: Thu, 6 Jul 2017 20:18:38 -0500 Subject: [PATCH] ... --- lib/fpa/Base/Dijkstra.h | 2 +- lib/fpa/Base/Dijkstra.hxx | 2 +- lib/fpa/Base/DijkstraBase.h | 2 +- lib/fpa/Base/DijkstraBase.hxx | 7 ++-- lib/fpa/Image/SkeletonFilter.h | 2 +- lib/fpa/Image/SkeletonFilter.hxx | 2 +- tests/image/CMakeLists.txt | 10 +++--- tests/image/Dijkstra_Gaussian.cxx | 21 +++--------- tests/image/Dijkstra_Identity.cxx | 21 +++--------- tests/image/RandomWalker.cxx | 53 ++++++++++--------------------- 10 files changed, 37 insertions(+), 85 deletions(-) diff --git a/lib/fpa/Base/Dijkstra.h b/lib/fpa/Base/Dijkstra.h index c93d575..11f5538 100644 --- a/lib/fpa/Base/Dijkstra.h +++ b/lib/fpa/Base/Dijkstra.h @@ -47,7 +47,7 @@ namespace fpa virtual ~Dijkstra( ); virtual void _AfterGenerateData( ) override; - virtual void _UpdateOutputValue( const TNode& n ) override; + virtual void _UpdateOutputValue( TNode& n ) override; private: // Purposely not implemented. diff --git a/lib/fpa/Base/Dijkstra.hxx b/lib/fpa/Base/Dijkstra.hxx index be35981..85380aa 100644 --- a/lib/fpa/Base/Dijkstra.hxx +++ b/lib/fpa/Base/Dijkstra.hxx @@ -74,7 +74,7 @@ _AfterGenerateData( ) // ------------------------------------------------------------------------- template< class _TAlgorithm, class _TMST > void fpa::Base::Dijkstra< _TAlgorithm, _TMST >:: -_UpdateOutputValue( const TNode& n ) +_UpdateOutputValue( TNode& n ) { this->Superclass::_UpdateOutputValue( n ); this->GetMinimumSpanningTree( )->SetParent( n.Vertex, n.Parent ); diff --git a/lib/fpa/Base/DijkstraBase.h b/lib/fpa/Base/DijkstraBase.h index 8878bb7..4f08eb9 100644 --- a/lib/fpa/Base/DijkstraBase.h +++ b/lib/fpa/Base/DijkstraBase.h @@ -60,7 +60,7 @@ namespace fpa DijkstraBase( ); virtual ~DijkstraBase( ); - virtual TOutputValue _ComputeOutputValue( const TNode& n ) override; + virtual void _ComputeOutputValue( TNode& n ) override; virtual void _QueueClear( ) override; virtual TNode _QueuePop( ) override; virtual void _QueuePush( const TNode& node ) override; diff --git a/lib/fpa/Base/DijkstraBase.hxx b/lib/fpa/Base/DijkstraBase.hxx index 6f4937e..d04ecf5 100644 --- a/lib/fpa/Base/DijkstraBase.hxx +++ b/lib/fpa/Base/DijkstraBase.hxx @@ -42,12 +42,11 @@ fpa::Base::DijkstraBase< _TAlgorithm >:: // ------------------------------------------------------------------------- template< class _TAlgorithm > -typename fpa::Base::DijkstraBase< _TAlgorithm >:: -TOutputValue fpa::Base::DijkstraBase< _TAlgorithm >:: -_ComputeOutputValue( const TNode& n ) +void fpa::Base::DijkstraBase< _TAlgorithm >:: +_ComputeOutputValue( TNode& n ) { TOutputValue c = this->m_WeightFunction->Evaluate( n.Vertex, n.Parent ); - return( c + this->_GetOutputValue( n.Parent ) ); + n.Value = c + this->_GetOutputValue( n.Parent ); } // ------------------------------------------------------------------------- diff --git a/lib/fpa/Image/SkeletonFilter.h b/lib/fpa/Image/SkeletonFilter.h index 11c2a74..91ba5b8 100644 --- a/lib/fpa/Image/SkeletonFilter.h +++ b/lib/fpa/Image/SkeletonFilter.h @@ -72,7 +72,7 @@ namespace fpa virtual ~_TDijkstra( ); virtual void _BeforeGenerateData( ) override; - virtual void _UpdateOutputValue( const TNode& n ) override; + virtual void _UpdateOutputValue( TNode& n ) override; private: // Purposely not implemented diff --git a/lib/fpa/Image/SkeletonFilter.hxx b/lib/fpa/Image/SkeletonFilter.hxx index 6a32237..aa02e59 100644 --- a/lib/fpa/Image/SkeletonFilter.hxx +++ b/lib/fpa/Image/SkeletonFilter.hxx @@ -44,7 +44,7 @@ _BeforeGenerateData( ) // ------------------------------------------------------------------------- template< class _TInputImage, class _TDistanceMap > void fpa::Image::SkeletonFilter< _TInputImage, _TDistanceMap >::_TDijkstra:: -_UpdateOutputValue( const TNode& n ) +_UpdateOutputValue( TNode& n ) { typedef typename _TSkeletonQueue::value_type _TSkeletonQueueValue; diff --git a/tests/image/CMakeLists.txt b/tests/image/CMakeLists.txt index 06dfae8..b62186c 100644 --- a/tests/image/CMakeLists.txt +++ b/tests/image/CMakeLists.txt @@ -4,11 +4,11 @@ set( RegionGrow_Tautology RegionGrow_BinaryThreshold MoriSegmentation - # Dijkstra_Identity - # Dijkstra_Gaussian - # RandomWalker - # SkeletonFilter - # SkeletonToPolyData + Dijkstra_Identity + Dijkstra_Gaussian + RandomWalker + SkeletonFilter + SkeletonToPolyData ) foreach(_e ${_examples}) add_executable(${_pfx}${_e} ${_e}.cxx) diff --git a/tests/image/Dijkstra_Gaussian.cxx b/tests/image/Dijkstra_Gaussian.cxx index d0461ff..1e147c6 100644 --- a/tests/image/Dijkstra_Gaussian.cxx +++ b/tests/image/Dijkstra_Gaussian.cxx @@ -17,12 +17,12 @@ typedef fpa::Image::Functors::Dijkstra::Gaussian< TInputImage, TScalar > TWeight int main( int argc, char* argv[] ) { // Get arguments - if( argc < 8 ) + if( argc < 7 ) { std::cerr << "Usage: " << argv[ 0 ] << " input_image output_image output_marks alpha beta" - << " stop_at_one_front visual_debug ..." + << " stop_at_one_front ..." << std::endl; return( 1 ); @@ -33,7 +33,6 @@ int main( int argc, char* argv[] ) double alpha = std::atoi( argv[ 4 ] ); double beta = std::atoi( argv[ 5 ] ); bool stop_at_one_front = ( argv[ 6 ][ 0 ] == '1' ); - bool visual_debug = ( argv[ 7 ][ 0 ] == '1' ); // Create image TInputImage::Pointer image; @@ -45,15 +44,6 @@ int main( int argc, char* argv[] ) } // fi - // Interact with image - fpa::tests::image::Viewer< TFilter > viewer( image ); - if( visual_debug ) - { - viewer.ActivateSeedWidget( ); - viewer.Show( ); - - } // fi - // Prepare weight TWeight::Pointer weight = TWeight::New( ); weight->SetAlpha( alpha ); @@ -66,7 +56,7 @@ int main( int argc, char* argv[] ) filter->SetStopAtOneFront( stop_at_one_front ); // Get all seeds - for( int i = 8; i < argc; i += 2 ) + for( int i = 7; i < argc; i += 2 ) { if( i + 1 < argc ) { @@ -78,11 +68,8 @@ int main( int argc, char* argv[] ) } // fi } // rof - viewer.AssociateSeedsTo( filter ); - // Prepare visual debug and update - if( visual_debug ) - viewer.ObserveFilter( filter ); + // Execute filter filter->Update( ); // Save results diff --git a/tests/image/Dijkstra_Identity.cxx b/tests/image/Dijkstra_Identity.cxx index 57f3593..54d1511 100644 --- a/tests/image/Dijkstra_Identity.cxx +++ b/tests/image/Dijkstra_Identity.cxx @@ -17,11 +17,11 @@ typedef fpa::Image::Functors::Dijkstra::Identity< TInputImage, TScalar > TWeight int main( int argc, char* argv[] ) { // Get arguments - if( argc < 6 ) + if( argc < 5 ) { std::cerr << "Usage: " << argv[ 0 ] - << " output_image output_marks width height visual_debug ..." + << " output_image output_marks width height ..." << std::endl; return( 1 ); @@ -30,21 +30,11 @@ int main( int argc, char* argv[] ) std::string output_marks_filename = argv[ 2 ]; int width = std::atoi( argv[ 3 ] ); int height = std::atoi( argv[ 4 ] ); - bool visual_debug = ( argv[ 5 ][ 0 ] == '1' ); // Create image TInputImage::Pointer image; fpa::tests::image::CreateImage( image, 1, width, height, 1.0, 1.0 ); - // Interact with image - fpa::tests::image::Viewer< TFilter > viewer( image ); - if( visual_debug ) - { - viewer.ActivateSeedWidget( ); - viewer.Show( ); - - } // fi - // Prepare weight TWeight::Pointer weight = TWeight::New( ); @@ -54,7 +44,7 @@ int main( int argc, char* argv[] ) filter->SetWeightFunction( weight ); // Get all seeds - for( int i = 6; i < argc; i += 2 ) + for( int i = 5; i < argc; i += 2 ) { if( i + 1 < argc ) { @@ -66,11 +56,8 @@ int main( int argc, char* argv[] ) } // fi } // rof - viewer.AssociateSeedsTo( filter ); - // Prepare visual debug and update - if( visual_debug ) - viewer.ObserveFilter( filter ); + // Execute filter filter->Update( ); // Save results diff --git a/tests/image/RandomWalker.cxx b/tests/image/RandomWalker.cxx index 59c9105..45a15c1 100644 --- a/tests/image/RandomWalker.cxx +++ b/tests/image/RandomWalker.cxx @@ -22,20 +22,18 @@ int main( int argc, char* argv[] ) { std::cerr << "Usage: " << argv[ 0 ] - << " input_image [labels_image] output_image output_costs" - << " alpha beta visual_debug" + << " input_image labels_image output_image output_costs" + << " alpha beta" << std::endl; return( 1 ); } // fi - int idx = ( argc == 7 )? 2: 3; std::string input_image_filename = argv[ 1 ]; - std::string labels_image_filename = ( argc == 8 )? argv[ 2 ]: ""; - std::string output_image_filename = argv[ idx ]; - std::string output_costs_filename = argv[ idx + 1 ]; - double alpha = std::atof( argv[ idx + 2 ] ); - double beta = std::atof( argv[ idx + 3 ] ); - bool visual_debug = ( argv[ idx + 4 ][ 0 ] == '1' ); + std::string labels_image_filename = argv[ 2 ]; + std::string output_image_filename = argv[ 3 ]; + std::string output_costs_filename = argv[ 4 ]; + double alpha = std::atof( argv[ 5 ] ); + double beta = std::atof( argv[ 6 ] ); // Read image TInputImage::Pointer image; @@ -49,25 +47,11 @@ int main( int argc, char* argv[] ) // Read label TLabelImage::Pointer labels; - if( labels_image_filename != "" ) + std::string err1 = fpa::tests::image::Read( labels, labels_image_filename ); + if( err1 != "" ) { - std::string err1 = fpa::tests::image::Read( labels, labels_image_filename ); - if( err1 != "" ) - { - std::cerr << "Error caught: " << err1 << std::endl; - return( 1 ); - - } // fi - - } // fi - - // Interact with image - fpa::tests::image::Viewer< TFilter > viewer( image ); - if( visual_debug ) - { - if( labels.IsNull( ) ) - viewer.ActivateBrushWidget( ); - viewer.Show( ); + std::cerr << "Error caught: " << err1 << std::endl; + return( 1 ); } // fi @@ -80,14 +64,9 @@ int main( int argc, char* argv[] ) TFilter::Pointer filter = TFilter::New( ); filter->SetInput( image ); filter->SetWeightFunction( weight ); - if( labels.IsNull( ) ) - viewer.AssociateLabelsTo( filter ); - else - filter->SetLabels( labels ); + filter->SetLabels( labels ); - // Prepare visual debug and update - if( visual_debug ) - viewer.ObserveFilter( filter ); + // Execute filter try { filter->Update( ); @@ -100,12 +79,12 @@ int main( int argc, char* argv[] ) } // yrt // Save results - std::string err1 = - fpa::tests::image::Write( filter->GetMarks( ), output_image_filename ); std::string err2 = + fpa::tests::image::Write( filter->GetMarks( ), output_image_filename ); + std::string err3 = fpa::tests::image::Write( filter->GetOutput( ), output_costs_filename ); - if( err1 != "" ) std::cerr << "Error caught: " << err1 << std::endl; if( err2 != "" ) std::cerr << "Error caught: " << err2 << std::endl; + if( err3 != "" ) std::cerr << "Error caught: " << err3 << std::endl; return( 0 ); } -- 2.47.1