6 #include <itkImageFileReader.h>
7 #include <itkImageFileWriter.h>
8 #include <itkInvertIntensityImageFilter.h>
9 #include <itkMinimumMaximumImageCalculator.h>
10 #include <itkDanielssonDistanceMapImageFilter.h>
18 #include <itkConstNeighborhoodIterator.h>
19 #include <itkNeighborhoodIterator.h>
20 #include <itkImageToVTKImageFilter.h>
23 #include <vtkPoints.h>
24 #include <vtkCellArray.h>
25 #include <vtkFloatArray.h>
26 #include <vtkPolyData.h>
27 #include <vtkSmartPointer.h>
29 #include <fpa/Image/DijkstraWithSphereBacktracking.h>
30 #include <fpa/VTK/ImageMPR.h>
31 #include <fpa/VTK/Image3DObserver.h>
34 // -------------------------------------------------------------------------
35 const unsigned int Dim = 3;
36 typedef unsigned char TPixel;
37 typedef float TScalar;
38 typedef itk::Image< TPixel, Dim > TImage;
39 typedef itk::Image< TScalar, Dim > TScalarImage;
40 typedef itk::ImageFileReader< TImage > TImageReader;
41 typedef itk::ImageFileWriter< TScalarImage > TImageWriter;
43 // -------------------------------------------------------------------------
44 int main( int argc, char* argv[] )
49 << "Usage: " << argv[ 0 ]
50 << " input_image output_image"
55 std::string input_image_fn = argv[ 1 ];
56 std::string output_image_fn = argv[ 2 ];
59 TImageReader::Pointer input_image_reader = TImageReader::New( );
60 input_image_reader->SetFileName( input_image_fn );
63 input_image_reader->Update( );
65 catch( itk::ExceptionObject& err )
67 std::cerr << "Error caught: " << err << std::endl;
73 typedef itk::MinimumMaximumImageCalculator< TImage > TMinMax;
74 TMinMax::Pointer minmax = TMinMax::New( );
75 minmax->SetImage( input_image_reader->GetOutput( ) );
78 typedef itk::InvertIntensityImageFilter< TImage > TInvert;
79 TInvert::Pointer invert = TInvert::New( );
80 invert->SetInput( input_image_reader->GetOutput( ) );
81 invert->SetMaximum( minmax->GetMaximum( ) );
83 typedef itk::DanielssonDistanceMapImageFilter< TImage, TScalarImage > TDistance;
84 TDistance::Pointer distance = TDistance::New( );
85 distance->SetInput( invert->GetOutput( ) );
86 distance->InputIsBinaryOn( );
87 distance->SquaredDistanceOn( );
88 std::clock_t start = std::clock( );
90 std::clock_t end = std::clock( );
91 double seconds = double( end - start ) / double( CLOCKS_PER_SEC );
92 std::cout << "Distance map time = " << seconds << std::endl;
94 TImageWriter::Pointer writer = TImageWriter::New( );
95 writer->SetInput( distance->GetOutput( ) );
96 writer->SetFileName( output_image_fn );