static void
PrintCommandLineUsage(const int argc, const char * const argv[])
{
std::cerr << "Missing Parameters " << std::endl;
std::cerr << "Usage: " << argv[0];
std::cerr << " inputImage outputImage seedX seedY";
std::cerr << " Sigma SigmoidAlpha SigmoidBeta TimeThreshold StoppingValue";
std::cerr
<< " smoothingOutputImage gradientMagnitudeOutputImage sigmoidOutputImage"
<< std::endl;
for (int qq = 0; qq < argc; ++qq)
{
std::cout << "argv[" << qq << "] = " << argv[qq] << std::endl;
}
}
int
main(int argc, char * argv[])
{
if (argc != 13)
{
PrintCommandLineUsage(argc, argv);
return EXIT_FAILURE;
}
using InternalPixelType = float;
using OutputPixelType = unsigned char;
using ThresholdingFilterType =
const InternalPixelType timeThreshold = std::stod(argv[8]);
thresholder->SetLowerThreshold(0.0);
thresholder->SetUpperThreshold(timeThreshold);
thresholder->SetOutsideValue(0);
thresholder->SetInsideValue(255);
reader->SetFileName(argv[1]);
writer->SetFileName(argv[2]);
using CastFilterType =
using SmoothingFilterType =
InternalImageType>;
using GradientFilterType =
InternalImageType>;
using SigmoidFilterType =
sigmoid->SetOutputMinimum(0.0);
sigmoid->SetOutputMaximum(1.0);
using FastMarchingFilterType =
smoothing->SetInput(reader->GetOutput());
gradientMagnitude->SetInput(smoothing->GetOutput());
sigmoid->SetInput(gradientMagnitude->GetOutput());
fastMarching->SetInput(sigmoid->GetOutput());
thresholder->SetInput(fastMarching->GetOutput());
writer->SetInput(thresholder->GetOutput());
smoothing->SetTimeStep(0.125);
smoothing->SetNumberOfIterations(5);
smoothing->SetConductanceParameter(9.0);
const double sigma = std::stod(argv[5]);
gradientMagnitude->SetSigma(sigma);
const double alpha = std::stod(argv[6]);
const double beta = std::stod(argv[7]);
sigmoid->SetAlpha(alpha);
sigmoid->SetBeta(beta);
using NodeContainer = FastMarchingFilterType::NodeContainer;
using NodeType = FastMarchingFilterType::NodeType;
seedPosition[0] = std::stoi(argv[3]);
seedPosition[1] = std::stoi(argv[4]);
NodeType node;
constexpr double seedValue = 0.0;
node.SetValue(seedValue);
node.SetIndex(seedPosition);
seeds->Initialize();
seeds->InsertElement(0, node);
fastMarching->SetTrialPoints(seeds);
try
{
caster1->SetInput(smoothing->GetOutput());
writer1->SetInput(caster1->GetOutput());
writer1->SetFileName(argv[10]);
caster1->SetOutputMinimum(0);
caster1->SetOutputMaximum(255);
writer1->Update();
}
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return EXIT_FAILURE;
}
try
{
caster2->SetInput(gradientMagnitude->GetOutput());
writer2->SetInput(caster2->GetOutput());
writer2->SetFileName(argv[11]);
caster2->SetOutputMinimum(0);
caster2->SetOutputMaximum(255);
writer2->Update();
}
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return EXIT_FAILURE;
}
try
{
caster3->SetInput(sigmoid->GetOutput());
writer3->SetInput(caster3->GetOutput());
writer3->SetFileName(argv[12]);
caster3->SetOutputMinimum(0);
caster3->SetOutputMaximum(255);
writer3->Update();
}
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return EXIT_FAILURE;
}
fastMarching->SetOutputSize(
reader->GetOutput()->GetBufferedRegion().GetSize());
const double stoppingTime = std::stod(argv[9]);
fastMarching->SetStoppingValue(stoppingTime);
try
{
writer->Update();
}
{
std::cerr << "Exception caught !" << std::endl;
std::cerr << excep << std::endl;
return EXIT_FAILURE;
}
try
{
caster4->SetInput(fastMarching->GetOutput());
writer4->SetInput(caster4->GetOutput());
writer4->SetFileName("FastMarchingFilterOutput4.png");
caster4->SetOutputMinimum(0);
caster4->SetOutputMaximum(255);
writer4->Update();
}
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return EXIT_FAILURE;
}
mapWriter->SetInput(fastMarching->GetOutput());
mapWriter->SetFileName("FastMarchingFilterOutput4.mha");
mapWriter->Update();
speedWriter->SetInput(sigmoid->GetOutput());
speedWriter->SetFileName("FastMarchingFilterOutput3.mha");
speedWriter->Update();
gradientWriter->SetInput(gradientMagnitude->GetOutput());
gradientWriter->SetFileName("FastMarchingFilterOutput2.mha");
gradientWriter->Update();
return EXIT_SUCCESS;
}
Binarize an input image by thresholding.
This filter performs anisotropic diffusion on a scalar itk::Image using the modified curvature diffus...
Standard exception handling object.
Solve an Eikonal equation using Fast Marching.
Computes the Magnitude of the Gradient of an image by convolution with the first derivative of a Gaus...
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.
Computes the sigmoid function pixel-wise.
ImageBaseType::IndexType IndexType
constexpr unsigned int Dimension