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;
constexpr unsigned int Dimension = 2;
using OutputPixelType = unsigned char;
using ThresholdingFilterType =
auto thresholder = ThresholdingFilterType::New();
thresholder->SetUpperThreshold(10.0);
thresholder->SetLowerThreshold(0.0);
thresholder->SetOutsideValue(0);
thresholder->SetInsideValue(255);
using DiffusionFilterType =
InternalImageType>;
auto diffusion = DiffusionFilterType::New();
diffusion->SetNumberOfIterations(std::stoi(argv[4]));
diffusion->SetTimeStep(0.125);
diffusion->SetConductanceParameter(std::stod(argv[5]));
using LaplacianSegmentationLevelSetImageFilterType =
InternalImageType>;
const LaplacianSegmentationLevelSetImageFilterType::Pointer
laplacianSegmentation =
LaplacianSegmentationLevelSetImageFilterType::New();
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(input1);
laplacianSegmentation->SetInput(input2);
laplacianSegmentation->SetFeatureImage(diffusion->GetOutput());
thresholder->SetInput(laplacianSegmentation->GetOutput());
try
{
}
{
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;
}
Binarize an input image by thresholding.
Standard exception handling object.
This filter performs anisotropic diffusion on a scalar itk::Image using the classic Perona-Malik,...
Templated n-dimensional image class.
Segments structures in images based on a second derivative image features.
ITK_TEMPLATE_EXPORT void WriteImage(TImagePointer &&image, const std::string &filename, bool compress=false)
TOutputImage::Pointer ReadImage(const std::string &filename)