-#include <ctime>
-#include <iostream>
-#include <string>
-
-#include <itkImage.h>
-#include <itkImageFileReader.h>
-#include <itkImageFileWriter.h>
-#include <itkInvertIntensityImageFilter.h>
-#include <itkMinimumMaximumImageCalculator.h>
-#include <itkDanielssonDistanceMapImageFilter.h>
-
-// -------------------------------------------------------------------------
-const unsigned int Dim = 3;
-typedef unsigned char TPixel;
-typedef float TScalar;
-typedef itk::Image< TPixel, Dim > TImage;
-typedef itk::Image< TScalar, Dim > TScalarImage;
-typedef itk::ImageFileReader< TImage > TImageReader;
-typedef itk::ImageFileWriter< TScalarImage > TImageWriter;
-
-// -------------------------------------------------------------------------
-int main( int argc, char* argv[] )
-{
- if( argc < 3 )
- {
- std::cerr
- << "Usage: " << argv[ 0 ]
- << " input_image output_image"
- << std::endl;
- return( 1 );
-
- } // fi
- std::string input_image_fn = argv[ 1 ];
- std::string output_image_fn = argv[ 2 ];
-
- // Read image
- TImageReader::Pointer input_image_reader = TImageReader::New( );
- input_image_reader->SetFileName( input_image_fn );
- try
- {
- input_image_reader->Update( );
- }
- catch( itk::ExceptionObject& err )
- {
- std::cerr << "Error caught: " << err << std::endl;
- return( 1 );
-
- } // yrt
-
- // Invert intensity
- typedef itk::MinimumMaximumImageCalculator< TImage > TMinMax;
- TMinMax::Pointer minmax = TMinMax::New( );
- minmax->SetImage( input_image_reader->GetOutput( ) );
- minmax->Compute( );
-
- typedef itk::InvertIntensityImageFilter< TImage > TInvert;
- TInvert::Pointer invert = TInvert::New( );
- invert->SetInput( input_image_reader->GetOutput( ) );
- invert->SetMaximum( minmax->GetMaximum( ) );
-
- typedef itk::DanielssonDistanceMapImageFilter< TImage, TScalarImage > TDistance;
- TDistance::Pointer distance = TDistance::New( );
- distance->SetInput( invert->GetOutput( ) );
- distance->InputIsBinaryOn( );
- distance->SquaredDistanceOn( );
- std::clock_t start = std::clock( );
- distance->Update( );
- std::clock_t end = std::clock( );
- double seconds = double( end - start ) / double( CLOCKS_PER_SEC );
- std::cout << "Distance map time = " << seconds << std::endl;
-
- TImageWriter::Pointer writer = TImageWriter::New( );
- writer->SetInput( distance->GetOutput( ) );
- writer->SetFileName( output_image_fn );
- writer->Update( );
-
- return( 0 );
-}
-
-// eof - $RCSfile$