int
main(int argc, char * argv[])
{
if (argc < 4)
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0]
<< " inputImageFile outputImageFile_NearestNeighbor"
<< " outputImageFile_Linear " << std::endl;
return EXIT_FAILURE;
}
using PixelComponentType = unsigned char;
reader->SetFileName(argv[1]);
writerNearest->SetFileName(argv[2]);
writerLinear->SetFileName(argv[3]);
using NearestInterpolatorType =
using LinearInterpolatorType =
nearestFilter->SetInterpolator(interpolatorNearest);
linearFilter->SetInterpolator(interpolatorLinear);
nearestFilter->SetTransform(transform);
linearFilter->SetTransform(transform);
auto defaultValue = itk::MakeFilled<PixelType>(50);
nearestFilter->SetDefaultPixelValue(defaultValue);
linearFilter->SetDefaultPixelValue(defaultValue);
ImageType::SpacingType spacing;
spacing[0] = .35;
spacing[1] = .35;
nearestFilter->SetOutputSpacing(spacing);
linearFilter->SetOutputSpacing(spacing);
origin[0] = 0.4;
origin[1] = 0.4;
nearestFilter->SetOutputOrigin(origin);
linearFilter->SetOutputOrigin(origin);
nearestFilter->SetOutputDirection(direction);
linearFilter->SetOutputDirection(direction);
size[0] = 300;
size[1] = 300;
linearFilter->SetSize(size);
nearestFilter->SetInput(reader->GetOutput());
linearFilter->SetInput(reader->GetOutput());
writerNearest->SetInput(nearestFilter->GetOutput());
writerLinear->SetInput(linearFilter->GetOutput());
try
{
writerNearest->Update();
}
{
std::cerr << "Exception thrown " << std::endl;
std::cerr << excp << std::endl;
}
try
{
writerLinear->Update();
}
{
std::cerr << "Exception thrown " << std::endl;
std::cerr << excp << std::endl;
}
return EXIT_SUCCESS;
}