int
main(int argc, char * argv[])
{
if (argc < 3)
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " inputImageFile outputImageFile" << std::endl;
std::cerr << " [scalingFactor] [translationX translationY translationZ]"
<< std::endl;
std::cerr << " [rotationZinDegrees]" << std::endl;
return EXIT_FAILURE;
}
using PixelType = unsigned char;
ReaderType::Pointer reader = ReaderType::New();
WriterType::Pointer writer = WriterType::New();
reader->SetFileName(argv[1]);
writer->SetFileName(argv[2]);
FilterType::Pointer filter = FilterType::New();
try
{
reader->Update();
}
catch (const itk::ExceptionObject & excp)
{
std::cerr << excp << std::endl;
return EXIT_FAILURE;
}
ImageType::ConstPointer inputImage = reader->GetOutput();
ImageType::SpacingType spacing = inputImage->GetSpacing();
if (argc > 3)
{
double scale = std::stod(argv[3]);
{
spacing[i] *= scale;
}
filter->SetOutputSpacing(spacing);
filter->ChangeSpacingOn();
}
if (argc > 6)
{
translation[0] = std::stod(argv[4]);
translation[1] = std::stod(argv[5]);
translation[2] = std::stod(argv[6]);
origin += translation;
filter->SetOutputOrigin(origin);
filter->ChangeOriginOn();
}
if (argc > 7)
{
double additionalAngle = std::stod(argv[7]);
filter->SetOutputDirection(newDirection);
filter->ChangeDirectionOn();
}
filter->SetInput(reader->GetOutput());
writer->SetInput(filter->GetOutput());
try
{
writer->Update();
}
catch (const itk::ExceptionObject & excp)
{
std::cerr << excp << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}