int
main(int argc, char * argv[])
{
if (argc < 5)
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0]
<< " inputImageFile outputImageFile degrees scale"
<< std::endl;
return EXIT_FAILURE;
}
using InputPixelType = unsigned char;
using OutputPixelType = unsigned char;
reader->SetFileName(argv[1]);
writer->SetFileName(argv[2]);
const double angleInDegrees = std::stod(argv[3]);
const double scale = std::stod(argv[4]);
using FilterType =
using InterpolatorType =
filter->SetInterpolator(interpolator);
filter->SetDefaultPixelValue(100);
reader->Update();
const InputImageType::SpacingType & spacing =
reader->GetOutput()->GetSpacing();
reader->GetOutput()->GetDirection();
reader->GetOutput()->GetLargestPossibleRegion().
GetSize();
filter->SetOutputOrigin(origin);
filter->SetOutputSpacing(spacing);
filter->SetOutputDirection(direction);
filter->SetSize(size);
filter->SetInput(reader->GetOutput());
writer->SetInput(filter->GetOutput());
TransformType::InputPointType rotationCenter;
rotationCenter[0] = origin[0] + spacing[0] * size[0] / 2.0;
rotationCenter[1] = origin[1] + spacing[1] * size[1] / 2.0;
transform->SetCenter(rotationCenter);
const double degreesToRadians = std::atan(1.0) / 45.0;
const double angle = angleInDegrees * degreesToRadians;
transform->SetAngle(angle);
transform->SetScale(scale);
TransformType::OutputVectorType translation;
translation[0] = 13.0;
translation[1] = 17.0;
transform->SetTranslation(translation);
filter->SetTransform(transform);
try
{
writer->Update();
}
catch (const itk::ExceptionObject & excep)
{
std::cerr << "Exception caught !" << std::endl;
std::cerr << excep << std::endl;
}
return EXIT_SUCCESS;
}