]> Creatis software - FrontAlgorithms.git/commitdiff
Minor bugs
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Wed, 11 Mar 2015 22:45:14 +0000 (17:45 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Wed, 11 Mar 2015 22:45:14 +0000 (17:45 -0500)
appli/examples/example_ImageAlgorithmRegionGrow_MultipleThresholds.cxx
appli/examples/example_ImageAlgorithm_Skeletonization.cxx
lib/fpa/Image/RegionGrow.h
lib/fpa/Image/RegionGrowWithMultipleThresholds.hxx

index 0216bed6753465cafa38910bfb5421e1286cacf4..d2f6b2a383e0696e623adbeb06970e4dc478bfa6 100644 (file)
@@ -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( );
   }
index 7bc80a95896faac60a6972ecde2fac5f2f62b228..06ff8057bd5b7d3c37a39a56a4e424dc943f2788 100644 (file)
@@ -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 );
 }
 
index d65fa6cbbe815e9a3b3c21a290cc18357cec4421..dd7c851a5bf5324ad12b72d101a9f59910e57232 100644 (file)
@@ -1,11 +1,11 @@
 #ifndef __FPA__IMAGE__REGIONGROW__H__
 #define __FPA__IMAGE__REGIONGROW__H__
 
-#include <itkImageFunction.h>
 #include <itkImageToImageFilter.h>
 #include <itkIndex.h>
 #include <fpa/Base/RegionGrow.h>
 #include <fpa/Image/Algorithm.h>
+#include <fpa/Image/Functors/ImageFunction.h>
 
 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 );
index 2e8c995c20d26ece1a8992b09c2c703f0d604a9c..4725c549102e042b1155d4951cb709b237813231 100644 (file)
@@ -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;