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 << " DiffusionIterations ";
std::cerr << " DiffusionConductance ";
std::cerr << " PropagationWeight";
std::cerr << " InitialModelIsovalue";
std::cerr << " MaximumIterations" << 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(std::stoi(argv[4]));
diffusion->SetTimeStep(0.125);
diffusion->SetConductanceParameter(std::stod(argv[5]));
using LaplacianSegmentationLevelSetImageFilterType =
InternalImageType>;
laplacianSegmentation =
laplacianSegmentation->SetCurvatureScaling(1.0);
laplacianSegmentation->SetPropagationScaling(std::stod(argv[6]));
laplacianSegmentation->SetMaximumRMSError(0.002);
laplacianSegmentation->SetNumberOfIterations(std::stoi(argv[8]));
laplacianSegmentation->SetIsoSurfaceValue(std::stod(argv[7]));
diffusion->SetInput(reader1->GetOutput());
laplacianSegmentation->SetInput(reader2->GetOutput());
laplacianSegmentation->SetFeatureImage(diffusion->GetOutput());
thresholder->SetInput(laplacianSegmentation->GetOutput());
writer->SetInput(thresholder->GetOutput());
try
{
writer->Update();
}
catch (const itk::ExceptionObject & excep)
{
std::cerr << "Exception caught !" << std::endl;
std::cerr << excep << std::endl;
return EXIT_FAILURE;
}
std::cout << std::endl;
std::cout << "Max. no. iterations: "
<< laplacianSegmentation->GetNumberOfIterations() << std::endl;
std::cout << "Max. RMS error: "
<< laplacianSegmentation->GetMaximumRMSError() << std::endl;
std::cout << std::endl;
std::cout << "No. elpased iterations: "
<< laplacianSegmentation->GetElapsedIterations() << std::endl;
std::cout << "RMS change: " << laplacianSegmentation->GetRMSChange()
<< std::endl;
speedWriter->SetInput(laplacianSegmentation->GetSpeedImage());
speedWriter->SetFileName("speedImage.mha");
speedWriter->Update();
return EXIT_SUCCESS;
}