From: Leonardo Florez-Valencia Date: Tue, 17 Mar 2015 20:23:21 +0000 (-0500) Subject: More and more tests X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=dc4791c63d865f011d4fcac4112deb69e860491c;p=FrontAlgorithms.git More and more tests --- diff --git a/appli/examples/CMakeLists.txt b/appli/examples/CMakeLists.txt index a112096..2d0ebe6 100644 --- a/appli/examples/CMakeLists.txt +++ b/appli/examples/CMakeLists.txt @@ -1,7 +1,7 @@ IF(BUILD_EXAMPLES) SET( APPLIS - example + example_Thinning example_BinaryDistanceMap example_ImageAlgorithmRegionGrow_00 example_ImageAlgorithmDijkstra_00 diff --git a/appli/examples/example_ImageAlgorithmDijkstra_03.cxx b/appli/examples/example_ImageAlgorithmDijkstra_03.cxx index 185991f..0de8126 100644 --- a/appli/examples/example_ImageAlgorithmDijkstra_03.cxx +++ b/appli/examples/example_ImageAlgorithmDijkstra_03.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -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 index 0000000..abd6144 --- /dev/null +++ b/appli/examples/example_Thinning.cxx @@ -0,0 +1,40 @@ +#include "itkBinaryThinningImageFilter.h" +#include "itkImage.h" +#include "itkImageFileReader.h" +#include "itkImageFileWriter.h" +#include "itkRescaleIntensityImageFilter.h" + +typedef itk::Image ImageType; + +int main(int argc, char *argv[]) +{ + + typedef itk::ImageFileReader ImageReader; + ImageReader::Pointer reader = ImageReader::New(); + std::string fileName = argv[1]; + reader->SetFileName(fileName); + reader->Update(); + ImageType::Pointer image = reader->GetOutput(); + + typedef itk::BinaryThinningImageFilter 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; +} +