int
main(int argc, char * argv[])
{
if (argc < 4)
{
std::cerr << "Usage: " << std::endl;
std::cerr
<< argv[0]
<< " inputImageFile outputImageFile sigma [RescaledOutputImageFile] "
<< std::endl;
return EXIT_FAILURE;
}
using InputPixelType = float;
using OutputPixelType = float;
using FilterType =
reader->SetFileName(argv[1]);
filterX1->SetDirection(0);
filterY1->SetDirection(1);
filterX2->SetDirection(0);
filterY2->SetDirection(1);
const bool normalizeAcrossScale = false;
filterX1->SetNormalizeAcrossScale(normalizeAcrossScale);
filterY1->SetNormalizeAcrossScale(normalizeAcrossScale);
filterX2->SetNormalizeAcrossScale(normalizeAcrossScale);
filterY2->SetNormalizeAcrossScale(normalizeAcrossScale);
filterX1->SetInput(reader->GetOutput());
filterY1->SetInput(filterX1->GetOutput());
filterY2->SetInput(reader->GetOutput());
filterX2->SetInput(filterY2->GetOutput());
const double sigma = std::stod(argv[3]);
filterX1->SetSigma(sigma);
filterY1->SetSigma(sigma);
filterX2->SetSigma(sigma);
filterY2->SetSigma(sigma);
using AddFilterType =
itk::AddImageFilter<OutputImageType, OutputImageType, OutputImageType>;
addFilter->SetInput1(filterY1->GetOutput());
addFilter->SetInput2(filterX2->GetOutput());
try
{
addFilter->Update();
}
catch (const itk::ExceptionObject & err)
{
std::cout << "ExceptionObject caught !" << std::endl;
std::cout << err << std::endl;
return EXIT_FAILURE;
}
using WritePixelType = float;
writer->SetInput(addFilter->GetOutput());
writer->SetFileName(argv[2]);
writer->Update();
if (argc > 4)
{
using CharPixelType = unsigned char;
using RescaleFilterType =
rescale->SetInput(addFilter->GetOutput());
rescale->SetOutputMinimum(0);
rescale->SetOutputMaximum(255);
charWriter->SetFileName(argv[4]);
charWriter->SetInput(rescale->GetOutput());
charWriter->Update();
}
return EXIT_SUCCESS;
}