int
main(int argc, char * argv[])
{
if (argc < 2)
{
std::cerr << "Usage: " << argv[0] << " <inputFileName>"
<< " [scalingFactor]"
<< " [translationX translationY translationZ]"
<< " [rotationZinDegrees]" << std::endl;
return EXIT_FAILURE;
}
const char * inputFileName = argv[1];
double scalingFactor = 1.0;
if (argc > 3)
{
scalingFactor = std::stod(argv[3]);
}
double translationX = 0.0;
if (argc > 3)
{
translationX = std::stod(argv[3]);
}
double translationY = 0.0;
if (argc > 4)
{
translationY = std::stod(argv[4]);
}
double translationZ = 0.0;
if (argc > 5)
{
translationZ = std::stod(argv[5]);
}
double rotationZ = 0.0;
if (argc > 6)
{
rotationZ = std::stod(argv[6]);
}
using PixelType = unsigned char;
reader->SetFileName(inputFileName);
try
{
reader->UpdateOutputInformation();
}
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
}
std::cout << "Original image: " << inputImage << std::endl;
filter->SetInput(reader->GetOutput());
const ImageType::SpacingType spacing(scalingFactor);
filter->SetOutputSpacing(spacing);
filter->ChangeSpacingOn();
translation[0] = translationX;
translation[1] = translationY;
translation[2] = translationZ;
origin += translation;
filter->SetOutputOrigin(origin);
filter->ChangeOriginOn();
filter->SetOutputDirection(newDirection);
filter->ChangeDirectionOn();
try
{
filter->UpdateOutputInformation();
}
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
}
std::cout << "**************************************" << std::endl;
std::cout << "Changed image: " << output << std::endl;
return EXIT_SUCCESS;
}