From: Leonardo Florez-Valencia Date: Wed, 18 Nov 2015 21:04:57 +0000 (-0500) Subject: Big bug smashed X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=9ae3f450aeb341b389d3e96567b9349a89b36c9b;p=FrontAlgorithms.git Big bug smashed --- diff --git a/appli/examples/CMakeLists.txt b/appli/examples/CMakeLists.txt index 16b2c26..b2d1450 100644 --- a/appli/examples/CMakeLists.txt +++ b/appli/examples/CMakeLists.txt @@ -1,11 +1,11 @@ -#SET( -# SIMPLE_EXAMPLES -# example_Image_Dijkstra_EndPointDetection_WithoutVTK -# ) -#FOREACH(EX ${SIMPLE_EXAMPLES}) -# ADD_EXECUTABLE(${EX} ${EX}.cxx) -# TARGET_LINK_LIBRARIES(${EX} FrontAlgorithms) -#ENDFOREACH(EX) +SET( + SIMPLE_EXAMPLES + example_Image_Dijkstra_EndPointDetection_WithoutVTK + ) +FOREACH(EX ${SIMPLE_EXAMPLES}) + ADD_EXECUTABLE(${EX} ${EX}.cxx) + TARGET_LINK_LIBRARIES(${EX} FrontAlgorithms) +ENDFOREACH(EX) SET( SIMPLE_VTK_EXAMPLES diff --git a/appli/examples/example_Image_Dijkstra_EndPointDetection.cxx b/appli/examples/example_Image_Dijkstra_EndPointDetection.cxx index 8a6dec2..9e79437 100644 --- a/appli/examples/example_Image_Dijkstra_EndPointDetection.cxx +++ b/appli/examples/example_Image_Dijkstra_EndPointDetection.cxx @@ -9,9 +9,11 @@ #include +#include + #include #include -#include +#include #include #include #include @@ -20,7 +22,7 @@ #include "fpa_Utility.h" // ------------------------------------------------------------------------- -const unsigned int Dim = 2; +const unsigned int Dim = 3; typedef unsigned char TPixel; typedef float TScalar; typedef itk::Image< TPixel, Dim > TImage; @@ -66,10 +68,37 @@ int main( int argc, char* argv[] ) vtk_input_image->SetInput( input_image ); vtk_input_image->Update( ); + vtkSmartPointer outline = + vtkSmartPointer::New(); + outline->SetBounds(vtk_input_image->GetOutput( )->GetBounds()); + + vtkSmartPointer mapper = + vtkSmartPointer::New( ); + mapper->SetInputConnection( outline->GetOutputPort( ) ); + + vtkSmartPointer actor = + vtkSmartPointer::New( ); + actor->SetMapper( mapper ); + vtkSmartPointer aRenderer = + vtkSmartPointer::New(); + vtkSmartPointer renWin = + vtkSmartPointer::New(); + renWin->AddRenderer(aRenderer); + + vtkSmartPointer iren = + vtkSmartPointer::New(); + iren->SetRenderWindow(renWin); + + aRenderer->AddActor( actor ); +iren->Initialize(); + iren->Start(); + + /* fpa_Utility::Viewer2DWithSeeds viewer; viewer.SetImage( vtk_input_image->GetOutput( ) ); while( viewer.GetNumberOfSeeds( ) == 0 ) viewer.Start( ); + */ // Compute squared distance map itk::SignedMaurerDistanceMapImageFilter< TImage, TScalarImage >::Pointer @@ -106,15 +135,21 @@ int main( int argc, char* argv[] ) // Associate seed TImage::PointType pnt; TImage::IndexType idx; - viewer.GetSeed( pnt, 0 ); + /* + viewer.GetSeed( pnt, 0 ); + */ + pnt[ 0 ] = 0.879066; + pnt[ 1 ] = -109.36591; + pnt[ 2 ] = 1942.480988; + if( input_image->TransformPhysicalPointToIndex( pnt, idx ) ) filter->AddSeed( idx, 0 ); // Prepare graphical debugger - typedef fpa::VTK::Image2DObserver< TFilter, vtkRenderWindow > TDebugger; + typedef fpa::VTK::Image3DObserver< TFilter, vtkRenderWindow > TDebugger; TDebugger::Pointer debugger = TDebugger::New( ); - debugger->SetRenderWindow( viewer.Window ); - debugger->SetRenderPercentage( 0.01 ); + debugger->SetRenderWindow( renWin ); + debugger->SetRenderPercentage( 0.0001 ); filter->AddObserver( itk::AnyEvent( ), debugger ); filter->ThrowEventsOn( ); @@ -144,7 +179,7 @@ int main( int argc, char* argv[] ) endpoints_actor->SetMapper( endpoints_mapper ); endpoints_actor->GetProperty( )->SetColor( 0, 1, 0 ); endpoints_actor->GetProperty( )->SetPointSize( 5 ); - viewer.Renderer->AddActor( endpoints_actor ); + aRenderer->AddActor( endpoints_actor ); TVertices2PD bifurcations2pd = TVertices2PD::New( ); bifurcations2pd->SetInput( filter->GetBifurcations( ) ); @@ -160,11 +195,11 @@ int main( int argc, char* argv[] ) bifurcations_actor->SetMapper( bifurcations_mapper ); bifurcations_actor->GetProperty( )->SetColor( 1, 0, 0 ); bifurcations_actor->GetProperty( )->SetPointSize( 5 ); - viewer.Renderer->AddActor( bifurcations_actor ); + aRenderer->AddActor( bifurcations_actor ); // Some more interaction and finish - viewer.Render( ); - viewer.Start( ); +iren->Initialize(); + iren->Start(); // Save results err = fpa_Utility::SaveImage( filter->GetLabelImage( ), output_labels_fn ); diff --git a/lib/fpa/Base/Functors/InvertCostFunction.h b/lib/fpa/Base/Functors/InvertCostFunction.h index fa04ed4..06315c7 100644 --- a/lib/fpa/Base/Functors/InvertCostFunction.h +++ b/lib/fpa/Base/Functors/InvertCostFunction.h @@ -30,7 +30,7 @@ namespace fpa virtual C Evaluate( const C& input ) const { if( input < C( 0 ) ) - return( C( -1 ) / ( C( 1 ) + C( input ) ) ); + return( C( -1 ) / ( C( 1 ) - C( input ) ) ); else return( C( 1 ) / ( C( 1 ) + C( input ) ) ); }