#include <iostream>
int
main(int argc, char * argv[])
{
if (argc != 6)
{
std::cerr << "Usage: " << argv[0]
<< " inputImageFile spacingFraction sigmaFraction outputImageFileLabelImageInterpolator "
"outputImageFileNearestNeighborInterpolator"
<< std::endl;
return EXIT_FAILURE;
}
const char * const inputImageFile = argv[1];
const double spacingFraction = std::stod(argv[2]);
const double sigmaFraction = std::stod(argv[3]);
const char * const outputImageFileLabelImageInterpolator = argv[4];
const char * const outputImageFileNearestNeighborInterpolator = argv[5];
using PixelType = unsigned char;
const auto input = itk::ReadImage<ImageType>(inputImageFile);
resizeFilter->SetInput(input);
const ImageType::SpacingType inputSpacing{ input->GetSpacing() };
ImageType::SpacingType outputSpacing;
for (
unsigned int dim = 0; dim <
Dimension; ++dim)
{
outputSpacing[dim] = inputSpacing[dim] * spacingFraction;
}
resizeFilter->SetOutputSpacing(outputSpacing);
for (
unsigned int dim = 0; dim <
Dimension; ++dim)
{
outputSize[dim] = inputSize[dim] * inputSpacing[dim] / spacingFraction;
}
GaussianInterpolatorType::ArrayType sigma;
for (
unsigned int dim = 0; dim <
Dimension; ++dim)
{
sigma[dim] = outputSpacing[dim] * sigmaFraction;
}
gaussianInterpolator->SetSigma(sigma);
gaussianInterpolator->SetAlpha(3.0);
resizeFilter->SetInterpolator(gaussianInterpolator);
try
{
itk::WriteImage(resizeFilter->GetOutput(), outputImageFileLabelImageInterpolator,
true);
}
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
}
resizeFilter->SetInterpolator(nearestNeighborInterpolator);
try
{
itk::WriteImage(resizeFilter->GetOutput(), outputImageFileNearestNeighborInterpolator,
true);
}
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}