int
main(int argc, char * argv[])
{
if (argc < 4)
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0]
<< " inputImageFile outputImageFile "
"desiredPositiveCoordinateOrientation"
<< std::endl;
return EXIT_FAILURE;
}
std::string inputImageFile = argv[1];
std::string outputImageFile = argv[2];
};
if (desiredCoordinateOrientation ==
{
std::cerr << "Invalid desiredPositiveCoordinateOrientation: " << argv[3]
<< std::endl;
std::cerr << "Valid values are of the form LPS, RIP, etc.";
std::cerr << "Where each letter is either L or R, P or A, I or S."
<< std::endl;
return EXIT_FAILURE;
}
using PixelType = unsigned short;
reader->SetFileName(inputImageFile);
reader->UpdateOutputInformation();
auto pixelType = reader->GetImageIO()->GetPixelType();
auto componentType = reader->GetImageIO()->GetComponentType();
{
itkGenericOutputMacro(
"The input image is being converted to scalar unsigned short.");
}
auto inputDirection = reader->GetOutput()->GetDirection();
std::cout << "Input image direction: " << std::endl;
std::cout << "The input image has the following orientation: " << std::endl;
<< std::endl;
std::cout << "The re-orienting to approximately the desired orientation: "
<< std::endl;
std::cout << '\t' << desiredCoordinateOrientation << std::endl;
using OrientImageFilterType = itk::OrientImageFilter<ImageType, ImageType>;
orienter->SetInput(reader->GetOutput());
orienter->UseImageDirectionOn();
orienter->SetDesiredCoordinateOrientation(desiredCoordinateOrientation);
writer->SetFileName(outputImageFile);
writer->SetInput(orienter->GetOutput());
writer->Update();
return EXIT_SUCCESS;
}