#include <iostream>
int
main(int argc, char * argv[])
{
if (argc < 8)
{
std::cerr << "Missing Parameters " << std::endl;
std::cerr << "Usage: " << argv[0];
std::cerr
<< " inputImage outputImage conductanceTerm diffusionIterations "
"lowerThreshold outputScaleLevel gradientMode "
<< std::endl;
return EXIT_FAILURE;
}
using DiffusionFilterType =
VectorImageType>;
using GradientMagnitudeFilterType =
FileReaderType::Pointer reader = FileReaderType::New();
reader->SetFileName(argv[1]);
CastFilterType::Pointer caster = CastFilterType::New();
DiffusionFilterType::Pointer diffusion = DiffusionFilterType::New();
diffusion->SetNumberOfIterations(std::stoi(argv[4]));
diffusion->SetConductanceParameter(std::stod(argv[3]));
diffusion->SetTimeStep(0.125);
GradientMagnitudeFilterType::Pointer gradient =
GradientMagnitudeFilterType::New();
gradient->SetUsePrincipleComponents(std::stoi(argv[7]));
WatershedFilterType::Pointer watershed = WatershedFilterType::New();
watershed->SetLevel(std::stod(argv[6]));
watershed->SetThreshold(std::stod(argv[5]));
using ColormapFunctorType =
using ColormapFilterType =
RGBImageType,
ColormapFunctorType>;
ColormapFilterType::Pointer colormapper = ColormapFilterType::New();
FileWriterType::Pointer writer = FileWriterType::New();
writer->SetFileName(argv[2]);
caster->SetInput(reader->GetOutput());
diffusion->SetInput(caster->GetOutput());
gradient->SetInput(diffusion->GetOutput());
watershed->SetInput(gradient->GetOutput());
colormapper->SetInput(watershed->GetOutput());
writer->SetInput(colormapper->GetOutput());
try
{
writer->Update();
}
catch (
const itk::ExceptionObject &
e)
{
std::cerr <<
e << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}