]> Creatis software - FrontAlgorithms.git/commitdiff
Big bug smashed
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Wed, 18 Nov 2015 21:04:57 +0000 (16:04 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Wed, 18 Nov 2015 21:04:57 +0000 (16:04 -0500)
appli/examples/CMakeLists.txt
appli/examples/example_Image_Dijkstra_EndPointDetection.cxx
lib/fpa/Base/Functors/InvertCostFunction.h

index 16b2c265e850323c5d1c39ebb56f59d68ecec099..b2d145093e534171834808ce3bbc30a8c0449470 100644 (file)
@@ -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
index 8a6dec2e57d04289b393daec50ddfc30cd6c9341..9e79437b5a1409e0e94d0913c933d012b2f16259 100644 (file)
@@ -9,9 +9,11 @@
 
 #include <itkSignedMaurerDistanceMapImageFilter.h>
 
+#include <vtkOutlineSource.h>
+
 #include <fpa/Base/Functors/InvertCostFunction.h>
 #include <fpa/Image/DijkstraWithEndPointDetection.h>
-#include <fpa/VTK/Image2DObserver.h>
+#include <fpa/VTK/Image3DObserver.h>
 #include <fpa/IO/MinimumSpanningTreeWriter.h>
 #include <fpa/IO/UniqueValuesContainerWriter.h>
 #include <fpa/IO/MatrixValuesContainerWriter.h>
@@ -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<vtkOutlineSource> outline =
+    vtkSmartPointer<vtkOutlineSource>::New();
+  outline->SetBounds(vtk_input_image->GetOutput( )->GetBounds());
+
+  vtkSmartPointer<vtkPolyDataMapper> mapper =
+    vtkSmartPointer<vtkPolyDataMapper>::New( );
+  mapper->SetInputConnection( outline->GetOutputPort( ) );
+
+  vtkSmartPointer<vtkActor> actor =
+    vtkSmartPointer<vtkActor>::New( );
+  actor->SetMapper( mapper );
+ vtkSmartPointer<vtkRenderer> aRenderer =
+    vtkSmartPointer<vtkRenderer>::New();
+  vtkSmartPointer<vtkRenderWindow> renWin =
+    vtkSmartPointer<vtkRenderWindow>::New();
+  renWin->AddRenderer(aRenderer);
+
+  vtkSmartPointer<vtkRenderWindowInteractor> iren =
+    vtkSmartPointer<vtkRenderWindowInteractor>::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 );
index fa04ed4841625428bb0d84e4988e59040d5d8c68..06315c7cafd4ad64c4aef0c50035dd2399df1f6d 100644 (file)
@@ -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 ) ) );
           }