int
main(int argc, char * argv[])
{
if (argc < 5)
{
std::cerr << "Usage: " << argv[0];
std::cerr << " inputImageFile outputDistanceMapImageFile ";
std::cerr << " outputVoronoiMapImageFilter ";
std::cerr << " outputVectorMapImageFilter ";
std::cerr << std::endl;
return EXIT_FAILURE;
}
using InputPixelType = unsigned char;
using OutputPixelType = float;
using VoronoiPixelType = unsigned short;
constexpr unsigned int Dimension = 2;
using FilterType =
OutputImageType,
VoronoiImageType>;
auto filter = FilterType::New();
using RescalerType =
auto scaler = RescalerType::New();
auto reader = ReaderType::New();
auto 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);
try
{
writer->Update();
}
{
std::cerr << "Exception caught !" << std::endl;
std::cerr << exp << std::endl;
}
const char * voronoiMapFileName = argv[3];
auto voronoiWriter = VoronoiWriterType::New();
voronoiWriter->SetFileName(voronoiMapFileName);
voronoiWriter->SetInput(filter->GetVoronoiMap());
try
{
voronoiWriter->Update();
}
{
std::cerr << "Exception caught !" << std::endl;
std::cerr << exp << std::endl;
}
using OffsetImageType = FilterType::VectorImageType;
auto 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;
}
Standard exception handling object.
Data source that reads image data from a single file.
Writes image data to a single file.
Templated n-dimensional image class.
Applies a linear transformation to the intensity levels of the input Image.
This filter computes the signed distance map of the input image as an approximation with pixel accura...