3 #include <itkImageFileReader.h>
4 #include <itkSignedMaurerDistanceMapImageFilter.h>
5 #include <itkImageFileWriter.h>
7 // -------------------------------------------------------------------------
8 static const unsigned int Dim = 2;
9 typedef short TInputPixel;
10 typedef float TOutputPixel;
11 typedef itk::Image< TInputPixel, Dim > TInputImage;
12 typedef itk::Image< TOutputPixel, Dim > TOutputImage;
14 // -------------------------------------------------------------------------
15 int main( int argc, char* argv[] )
17 // Command configuration
21 << "Usage: " << argv[ 0 ] << " input_image output_image"
26 std::string input_image_filename = argv[ 1 ];
27 std::string output_image_filename = argv[ 2 ];
30 typedef itk::ImageFileReader< TInputImage > TReader;
31 TReader::Pointer reader = TReader::New( );
32 reader->SetFileName( input_image_filename );
35 typedef itk::SignedMaurerDistanceMapImageFilter< TInputImage, TOutputImage > TFilter;
36 TFilter::Pointer filter = TFilter::New( );
37 filter->SetInput( reader->GetOutput( ) );
38 filter->SetBackgroundValue( 0 );
39 filter->InsideIsPositiveOn( );
40 filter->SquaredDistanceOff( );
41 filter->UseImageSpacingOn( );
44 typedef itk::ImageFileWriter< TOutputImage > TWriter;
45 TWriter::Pointer writer = TWriter::New( );
46 writer->SetInput( filter->GetOutput( ) );
47 writer->SetFileName( output_image_filename );
54 catch( std::exception& err )
56 std::cerr << "Error caught: " << err.what( ) << std::endl;