]> Creatis software - FrontAlgorithms.git/commitdiff
More and more tests
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Tue, 17 Mar 2015 20:23:21 +0000 (15:23 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Tue, 17 Mar 2015 20:23:21 +0000 (15:23 -0500)
appli/examples/CMakeLists.txt
appli/examples/example_ImageAlgorithmDijkstra_03.cxx
appli/examples/example_Thinning.cxx [new file with mode: 0644]

index a112096765d893af7c7c873d6d91e6bac6983763..2d0ebe63e8ac5ba7e7296c7299c37a22fbc9a71c 100644 (file)
@@ -1,7 +1,7 @@
 IF(BUILD_EXAMPLES)
   SET(
     APPLIS
-    example
+    example_Thinning
     example_BinaryDistanceMap
     example_ImageAlgorithmRegionGrow_00
     example_ImageAlgorithmDijkstra_00
index 185991f46e96b45c0cab430e823e8276969ccd4b..0de81262791453d8f802238ce15b6ebbb3e37385 100644 (file)
@@ -22,6 +22,7 @@
 #include <vtkFloatArray.h>
 #include <vtkPolyData.h>
 #include <vtkSmartPointer.h>
+#include <vtkImageMarchingCubes.h>
 
 #include <fpa/Image/DijkstraWithSphereBacktracking.h>
 #include <fpa/VTK/ImageMPR.h>
@@ -89,7 +90,15 @@ int main( int argc, char* argv[] )
   view.SetSize( 800, 800 );
   view.SetImage( vtk_image->GetOutput( ) );
 
+  vtkSmartPointer< vtkImageMarchingCubes > mc =
+    vtkSmartPointer< vtkImageMarchingCubes >::New( );
+  mc->SetInputData( vtk_image->GetOutput( ) );
+  mc->SetValue( 0, 1e-2 );
+  mc->Update( );
+  view.AddPolyData( mc->GetOutput( ), 1, 1, 1, 0.4 );
+
   // Allow some interaction
+  view.Render( );
   view.Start( );
 
   TImage::IndexType seed_idx;
diff --git a/appli/examples/example_Thinning.cxx b/appli/examples/example_Thinning.cxx
new file mode 100644 (file)
index 0000000..abd6144
--- /dev/null
@@ -0,0 +1,40 @@
+#include "itkBinaryThinningImageFilter.h"
+#include "itkImage.h"
+#include "itkImageFileReader.h"
+#include "itkImageFileWriter.h"
+#include "itkRescaleIntensityImageFilter.h"
+typedef itk::Image<short, 3>  ImageType;
+int main(int argc, char *argv[])
+{
+  
+  typedef itk::ImageFileReader<ImageType> ImageReader;
+  ImageReader::Pointer reader = ImageReader::New();
+  std::string fileName = argv[1];
+  reader->SetFileName(fileName);
+  reader->Update();
+  ImageType::Pointer image = reader->GetOutput();
+  typedef itk::BinaryThinningImageFilter <ImageType, ImageType> BinaryThinningImageFilterType;
+  BinaryThinningImageFilterType::Pointer binaryThinningImageFilter = BinaryThinningImageFilterType::New();
+  binaryThinningImageFilter->SetInput(image);
+  binaryThinningImageFilter->Update();
+  // Rescale the image so that it can be seen (the output is 0 and 1, we want 0 and 255)
+  typedef itk::RescaleIntensityImageFilter< ImageType, ImageType > RescaleType;
+  RescaleType::Pointer rescaler = RescaleType::New();
+  rescaler->SetInput( binaryThinningImageFilter->GetOutput() );
+  rescaler->SetOutputMinimum(0);
+  rescaler->SetOutputMaximum(255);
+  rescaler->Update();
+  typedef  itk::ImageFileWriter< ImageType  > WriterType;
+  WriterType::Pointer writer = WriterType::New();
+  writer->SetFileName(argv[2]);
+  writer->SetInput(rescaler->GetOutput());
+  writer->Update();
+
+  return EXIT_SUCCESS;
+}