int main( int argc, char * argv[] )
{
if( argc < 5 )
{
std::cerr << "Usage: " << argv[0];
std::cerr << " inputImageFile outputDistanceMapImageFile ";
std::cerr << " outputVoronoiMapImageFile ";
std::cerr << " outputVectorMapImageFile ";
std::cerr << std::endl;
return EXIT_FAILURE;
}
typedef unsigned char InputPixelType;
typedef unsigned short OutputPixelType;
InputImageType, OutputImageType, OutputImageType > FilterType;
FilterType::Pointer filter = FilterType::New();
OutputImageType, OutputImageType > RescalerType;
RescalerType::Pointer scaler = RescalerType::New();
ReaderType::Pointer reader = ReaderType::New();
WriterType::Pointer writer = WriterType::New();
reader->SetFileName( argv[1] );
writer->SetFileName( argv[2] );
filter->SetInput( reader->GetOutput() );
scaler->SetInput( filter->GetOutput() );
writer->SetInput( scaler->GetOutput() );
scaler->SetOutputMaximum( 65535L );
scaler->SetOutputMinimum( 0L );
filter->InputIsBinaryOn();
writer->Update();
const char * voronoiMapFileName = argv[3];
scaler->SetInput( filter->GetVoronoiMap() );
writer->SetFileName( voronoiMapFileName );
writer->Update();
typedef FilterType::VectorImageType OffsetImageType;
WriterOffsetType::Pointer offsetWriter = WriterOffsetType::New();
offsetWriter->SetInput( filter->GetVectorDistanceMap() );
offsetWriter->SetFileName( argv[4] );
try
{
offsetWriter->Update();
}
{
std::cerr << "Exception caught !" << std::endl;
std::cerr << exp << std::endl;
}
return EXIT_SUCCESS;
}