int
main(int argc, char * argv[])
{
if (argc < 3)
{
std::cerr << "Missing parameters. " << std::endl;
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " inputImageFile outputImageFile" << std::endl;
return EXIT_FAILURE;
}
reader->SetFileName(argv[1]);
try
{
reader->Update();
inputImage = reader->GetOutput();
}
catch (const itk::ExceptionObject & err)
{
std::cerr << "ExceptionObject caught a !" << std::endl;
std::cerr << err << std::endl;
return EXIT_FAILURE;
}
outputImage->SetRegions(inputImage->GetRequestedRegion());
outputImage->CopyInformation(inputImage);
outputImage->Allocate();
ConstIteratorType inputIt(inputImage, inputImage->GetRequestedRegion());
IteratorType outputIt(outputImage, inputImage->GetRequestedRegion());
inputIt.SetDirection(0);
outputIt.SetDirection(0);
for (inputIt.GoToBegin(), outputIt.GoToBegin(); !inputIt.IsAtEnd();
outputIt.NextLine(), inputIt.NextLine())
{
inputIt.GoToBeginOfLine();
outputIt.GoToEndOfLine();
while (!inputIt.IsAtEndOfLine())
{
--outputIt;
outputIt.Set(inputIt.Get());
++inputIt;
}
}
writer->SetFileName(argv[2]);
writer->SetInput(outputImage);
try
{
writer->Update();
}
catch (const itk::ExceptionObject & err)
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}