int main( int argc, char * argv[] )
{
if( argc < 4 )
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " inputImageFile outputImageFile";
std::cerr << " [exampleAction={0,1,2,3}]" << std::endl;
return EXIT_FAILURE;
}
int exampleAction = 0;
if( argc >= 4 )
{
exampleAction = atoi( argv[3] );
}
const unsigned int Dimension = 2;
typedef unsigned char InputPixelType;
typedef unsigned char OutputPixelType;
ReaderType::Pointer reader = ReaderType::New();
WriterType::Pointer writer = WriterType::New();
reader->SetFileName( argv[1] );
writer->SetFileName( argv[2] );
FilterType::Pointer filter = FilterType::New();
TransformType::Pointer transform = TransformType::New();
filter->SetTransform( transform );
InputImageType, double > InterpolatorType;
InterpolatorType::Pointer interpolator = InterpolatorType::New();
filter->SetInterpolator( interpolator );
filter->SetDefaultPixelValue( 0 );
const double spacing[ Dimension ] = { 1.0, 1.0 };
filter->SetOutputSpacing( spacing );
const double origin[ Dimension ] = { 0.0, 0.0 };
filter->SetOutputOrigin( origin );
InputImageType::DirectionType direction;
direction.SetIdentity();
filter->SetOutputDirection( direction );
InputImageType::SizeType size;
size[0] = 300;
size[1] = 300;
filter->SetSize( size );
filter->SetInput( reader->GetOutput() );
writer->SetInput( filter->GetOutput() );
writer->Update();
TransformType::OutputVectorType translation;
translation[0] = -30;
translation[1] = -50;
transform->Translate( translation );
if( exampleAction == 1 )
{
writer->Update();
}
filter->SetDefaultPixelValue( 100 );
if( exampleAction == 2 )
{
writer->Update();
}
return EXIT_SUCCESS;
}