int
main(int argc, char * argv[])
{
if (argc < 3)
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0]
<< " inputImageFile outputImageFile [smoothingIterations]"
<< std::endl;
return EXIT_FAILURE;
}
const char * membershipImageFileName = argv[1];
const char * labelMapImageFileName = argv[2];
using InputPixelType = float;
reader->SetFileName(membershipImageFileName);
using LabelType = unsigned char;
using PriorType = float;
using PosteriorType = float;
using ClassifierFilterType =
LabelType,
PosteriorType,
PriorType>;
filter->SetInput(reader->GetOutput());
if (argv[3])
{
filter->SetNumberOfSmoothingIterations(std::stoi(argv[3]));
using ExtractedComponentImageType =
ClassifierFilterType::ExtractedComponentImageType;
ExtractedComponentImageType,
ExtractedComponentImageType>;
smoother->SetNumberOfIterations(1);
smoother->SetTimeStep(0.125);
smoother->SetConductanceParameter(3);
filter->SetSmoothingFilter(smoother);
}
using ClassifierOutputImageType = ClassifierFilterType::OutputImageType;
using RescalerType =
OutputImageType>;
rescaler->SetInput(filter->GetOutput());
rescaler->SetOutputMinimum(0);
rescaler->SetOutputMaximum(255);
writer->SetFileName(labelMapImageFileName);
writer->SetInput(rescaler->GetOutput());
try
{
writer->Update();
}
{
std::cerr << "Exception caught: " << std::endl;
std::cerr << excp << std::endl;
return EXIT_FAILURE;
}
filter->
Print(std::cout);
std::cout << "Test passed." << std::endl;
return EXIT_SUCCESS;
}