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;
}
typedef unsigned char PixelType;
const unsigned int Dimension = 3;
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();
}
{
std::cerr << excp << std::endl;
return EXIT_FAILURE;
}
ImageType::ConstPointer inputImage = reader->GetOutput();
ImageType::PointType origin = inputImage->GetOrigin();
ImageType::SpacingType spacing = inputImage->GetSpacing();
ImageType::DirectionType direction = inputImage->GetDirection();
if( argc > 3 )
{
double scale = atof( argv[3] );
for(unsigned int i=0; i<Dimension; i++)
{
spacing[i] *= scale;
}
filter->SetOutputSpacing( spacing );
filter->ChangeSpacingOn();
}
if( argc > 6 )
{
ImageType::PointType::VectorType translation;
translation[0] = atof ( argv[4] );
translation[1] = atof ( argv[5] );
translation[2] = atof ( argv[6] );
origin += translation;
filter->SetOutputOrigin( origin );
filter->ChangeOriginOn();
}
if( argc > 7 )
{
double additionalAngle = atof( argv[7] );
double angleInRadians = additionalAngle *
vnl_math::pi / 180.0;
ImageType::DirectionType newDirection = direction * rotation.
GetMatrix();
filter->SetOutputDirection( newDirection );
filter->ChangeDirectionOn();
}
filter->SetInput( reader->GetOutput() );
writer->SetInput( filter->GetOutput() );
try
{
writer->Update();
}
{
std::cerr << excp << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}