From 79df4abfecefc36c0dfca7d9f6f2978882de95dc Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Wed, 11 Mar 2015 17:45:14 -0500 Subject: [PATCH] Minor bugs --- ...AlgorithmRegionGrow_MultipleThresholds.cxx | 2 +- ...example_ImageAlgorithm_Skeletonization.cxx | 81 +++++++------------ lib/fpa/Image/RegionGrow.h | 8 +- .../RegionGrowWithMultipleThresholds.hxx | 2 + 4 files changed, 39 insertions(+), 54 deletions(-) diff --git a/appli/examples/example_ImageAlgorithmRegionGrow_MultipleThresholds.cxx b/appli/examples/example_ImageAlgorithmRegionGrow_MultipleThresholds.cxx index 0216bed..d2f6b2a 100644 --- a/appli/examples/example_ImageAlgorithmRegionGrow_MultipleThresholds.cxx +++ b/appli/examples/example_ImageAlgorithmRegionGrow_MultipleThresholds.cxx @@ -117,7 +117,7 @@ int main( int argc, char* argv[] ) { // Configure observer TObserver::Pointer obs = TObserver::New( ); - obs->SetImage( input_image, view.GetWindow( ) ); + obs->SetRenderWindow( view.GetWindow( ) ); algorithm->AddObserver( itk::AnyEvent( ), obs ); algorithm->ThrowEventsOn( ); } diff --git a/appli/examples/example_ImageAlgorithm_Skeletonization.cxx b/appli/examples/example_ImageAlgorithm_Skeletonization.cxx index 7bc80a9..06ff805 100644 --- a/appli/examples/example_ImageAlgorithm_Skeletonization.cxx +++ b/appli/examples/example_ImageAlgorithm_Skeletonization.cxx @@ -19,7 +19,7 @@ // ------------------------------------------------------------------------- const unsigned int Dim = 3; typedef short TPixel; -typedef double TScalar; +typedef float TScalar; typedef itk::Image< TPixel, Dim > TImage; typedef itk::Image< TScalar, Dim > TDistanceMap; typedef itk::ImageToVTKImageFilter< TImage > TVTKImage; @@ -43,12 +43,12 @@ typedef fpa::VTK::Image3DObserver< TDijkstra, vtkRenderWindow > TDijkstraObs; // ------------------------------------------------------------------------- int main( int argc, char* argv[] ) { - if( argc < 7 ) + if( argc < 8 ) { std::cerr << "Usage: " << argv[ 0 ] << " input_image thr_0 thr_1 step" - << " output_segmentation output_distancemap" + << " output_segmentation output_distancemap output_dijkstra" << " visual_debug" << std::endl; return( 1 ); @@ -60,9 +60,10 @@ int main( int argc, char* argv[] ) unsigned int step = std::atoi( argv[ 4 ] ); std::string output_segmentation_fn = argv[ 5 ]; std::string output_distancemap_fn = argv[ 6 ]; + std::string output_dijkstra_fn = argv[ 7 ]; bool visual_debug = false; - if( argc > 7 ) - visual_debug = ( std::atoi( argv[ 7 ] ) == 1 ); + if( argc > 8 ) + visual_debug = ( std::atoi( argv[ 8 ] ) == 1 ); // Read image TImageReader::Pointer input_image_reader = TImageReader::New( ); @@ -221,54 +222,34 @@ int main( int argc, char* argv[] ) view.Render( ); view.Start( ); - /* TODO - TDistanceMapWriter::Pointer distancemap_writer = - TDistanceMapWriter::New( ); - distancemap_writer->SetInput( distanceMap->GetOutput( ) ); - distancemap_writer->SetFileName( output_distancemap_fn ); - distancemap_writer->Update( ); - - TImageWriter::Pointer segmentation_writer = - TImageWriter::New( ); - segmentation_writer->SetInput( segmentor->GetOutput( ) ); - segmentation_writer->SetFileName( output_segmentation_fn ); - segmentation_writer->Update( ); - */ - - // Show result - /* - TVTKImage::Pointer output_image_vtk = TVTKImage::New( ); - output_image_vtk->SetInput( segmentor->GetOutput( ) ); - output_image_vtk->Update( ); - - vtkSmartPointer< vtkImageMarchingCubes > mc = - vtkSmartPointer< vtkImageMarchingCubes >::New( ); - mc->SetInputData( output_image_vtk->GetOutput( ) ); - mc->SetValue( - 0, - double( segmentor->GetInsideValue( ) ) * double( 0.95 ) - ); - mc->Update( ); - - // Let some interaction and close program - view.AddPolyData( mc->GetOutput( ), 0.1, 0.6, 0.8, 0.5 ); - view.Start( ); + itk::ImageFileWriter< TImage >::Pointer segmentation_writer = + itk::ImageFileWriter< TImage >::New( ); + segmentation_writer->SetInput( segmentor->GetOutput( ) ); + segmentation_writer->SetFileName( output_segmentation_fn ); - // Write resulting image - TImageWriter::Pointer output_image_writer = TImageWriter::New( ); - output_image_writer->SetInput( segmentor->GetOutput( ) ); - output_image_writer->SetFileName( output_image_fn ); - try - { - output_image_writer->Update( ); - } - catch( itk::ExceptionObject& err ) - { + itk::ImageFileWriter< TDistanceMap >::Pointer dmap_writer = + itk::ImageFileWriter< TDistanceMap >::New( ); + dmap_writer->SetInput( distanceMap->GetOutput( ) ); + dmap_writer->SetFileName( output_distancemap_fn ); + + itk::ImageFileWriter< TDistanceMap >::Pointer dijk_writer = + itk::ImageFileWriter< TDistanceMap >::New( ); + dijk_writer->SetInput( paths->GetOutput( ) ); + dijk_writer->SetFileName( output_dijkstra_fn ); + + try + { + segmentation_writer->Update( ); + dmap_writer->Update( ); + dijk_writer->Update( ); + } + catch( itk::ExceptionObject& err ) + { std::cerr << "Error caught: " << err << std::endl; - return( 1 ); + return( -1 ); + + } // yrt - } // yrt - */ return( 0 ); } diff --git a/lib/fpa/Image/RegionGrow.h b/lib/fpa/Image/RegionGrow.h index d65fa6c..dd7c851 100644 --- a/lib/fpa/Image/RegionGrow.h +++ b/lib/fpa/Image/RegionGrow.h @@ -1,11 +1,11 @@ #ifndef __FPA__IMAGE__REGIONGROW__H__ #define __FPA__IMAGE__REGIONGROW__H__ -#include #include #include #include #include +#include namespace fpa { @@ -31,7 +31,9 @@ namespace fpa typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; - typedef itk::ImageFunction< I, bool > TMembershipFunction; + typedef + fpa::Image::Functors::ImageFunction< I, bool > + TMembershipFunction; public: itkNewMacro( Self ); @@ -59,7 +61,7 @@ namespace fpa this->GetInput( ) ) this->m_MembershipFunction->SetInputImage( this->GetInput( ) ); - return( this->m_MembershipFunction->EvaluateAtIndex( n.Vertex ) ); + return( this->m_MembershipFunction->Evaluate( n.Vertex ) ); } else return( false ); diff --git a/lib/fpa/Image/RegionGrowWithMultipleThresholds.hxx b/lib/fpa/Image/RegionGrowWithMultipleThresholds.hxx index 2e8c995..4725c54 100644 --- a/lib/fpa/Image/RegionGrowWithMultipleThresholds.hxx +++ b/lib/fpa/Image/RegionGrowWithMultipleThresholds.hxx @@ -231,6 +231,8 @@ _Mark( const _TNode& n ) diff /= double( f->GetUpperThreshold( ) ) - double( hIt->first ); if( diff > this->m_LastDiff ) { + /* TODO: comment this for demo purposes + */ this->m_StopForced = true; this->m_StopThreshold = hIt->first; -- 2.47.1