int
main(int argc, char * argv[])
{
if (argc < 9)
{
std::cerr << "Missing Parameters " << std::endl;
std::cerr << "Usage: " << argv[0];
std::cerr << " InputImage InitialModel OutputImage";
std::cerr << " CannyThreshold ";
std::cerr << " CannyVariance ";
std::cerr << " AdvectionWeight";
std::cerr << " InitialModelIsovalue";
std::cerr << " MaximumIterations";
std::cerr << " [OutputSpeedImage]" << std::endl;
return EXIT_FAILURE;
}
using InternalPixelType = float;
using OutputPixelType = unsigned char;
using ThresholdingFilterType =
thresholder->SetUpperThreshold(10.0);
thresholder->SetLowerThreshold(0.0);
thresholder->SetOutsideValue(0);
thresholder->SetInsideValue(255);
reader1->SetFileName(argv[1]);
reader2->SetFileName(argv[2]);
writer->SetFileName(argv[3]);
using DiffusionFilterType =
InternalImageType>;
diffusion->SetNumberOfIterations(5);
diffusion->SetTimeStep(0.125);
diffusion->SetConductanceParameter(1.0);
using CannySegmentationLevelSetImageFilterType =
InternalImageType>;
cannySegmentation->SetAdvectionScaling(std::stod(argv[6]));
cannySegmentation->SetCurvatureScaling(1.0);
cannySegmentation->SetPropagationScaling(0.0);
cannySegmentation->SetMaximumRMSError(0.01);
cannySegmentation->SetNumberOfIterations(std::stoi(argv[8]));
cannySegmentation->SetThreshold(std::stod(argv[4]));
cannySegmentation->SetVariance(std::stod(argv[5]));
cannySegmentation->SetIsoSurfaceValue(std::stod(argv[7]));
diffusion->SetInput(reader1->GetOutput());
cannySegmentation->SetInput(reader2->GetOutput());
cannySegmentation->SetFeatureImage(diffusion->GetOutput());
thresholder->SetInput(cannySegmentation->GetOutput());
writer->SetInput(thresholder->GetOutput());
try
{
writer->Update();
}
{
std::cerr << "Exception caught !" << std::endl;
std::cerr << excep << std::endl;
return EXIT_FAILURE;
}
std::cout << std::endl;
std::cout << "Max. no. iterations: "
<< cannySegmentation->GetNumberOfIterations() << std::endl;
std::cout << "Max. RMS error: " << cannySegmentation->GetMaximumRMSError()
<< std::endl;
std::cout << std::endl;
std::cout << "No. elpased iterations: "
<< cannySegmentation->GetElapsedIterations() << std::endl;
std::cout << "RMS change: " << cannySegmentation->GetRMSChange()
<< std::endl;
if (argc > 9)
{
const char * speedImageFileName = argv[9];
cannySegmentation->GenerateSpeedImage();
using SpeedImageType =
CannySegmentationLevelSetImageFilterType::SpeedImageType;
speedWriter->SetInput(cannySegmentation->GetSpeedImage());
speedWriter->SetFileName(speedImageFileName);
try
{
speedWriter->Update();
}
{
std::cerr << "Exception caught ! while writing the speed image"
<< std::endl;
std::cerr << "Filename : " << speedImageFileName << std::endl;
std::cerr << excep << std::endl;
return EXIT_FAILURE;
}
}
return EXIT_SUCCESS;
}