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,4}]" << std::endl;
return EXIT_FAILURE;
}
int exampleAction = 0;
if( argc >= 4 )
{
exampleAction = atoi( argv[3] );
}
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] );
InputImageType, OutputImageType > FilterType;
FilterType::Pointer filter = FilterType::New();
TransformType::Pointer transform = TransformType::New();
InputImageType, double > InterpolatorType;
InterpolatorType::Pointer interpolator = InterpolatorType::New();
filter->SetInterpolator( interpolator );
filter->SetDefaultPixelValue( 50 );
{
const double spacing[
Dimension ] = { 1.0, 1.0 };
filter->SetOutputSpacing( spacing );
}
filter->SetOutputDirection( reader->GetOutput()->GetDirection() );
{
const double origin[
Dimension ] = { 30.0, 40.0 };
filter->SetOutputOrigin( origin );
}
size[0] = 300;
size[1] = 300;
filter->SetInput( reader->GetOutput() );
writer->SetInput( filter->GetOutput() );
transform->SetIdentity();
filter->SetTransform( transform );
if( exampleAction == 0 )
{
writer->Update();
}
size[0] = 150;
size[1] = 200;
filter->SetSize( size );
{
const double origin[
Dimension ] = { 60.0, 30.0 };
filter->SetOutputOrigin( origin );
}
if( exampleAction == 1 )
{
writer->Update();
}
if( exampleAction == 2 )
{
writer->Update();
}
{
const double origin[
Dimension ] = { 0.0, 0.0 };
filter->SetOutputOrigin( origin );
}
{
const double spacing[
Dimension ] = { 2.0, 3.0 };
filter->SetOutputSpacing( spacing );
}
size[0] = 80;
size[1] = 50;
filter->SetSize( size );
if( exampleAction == 3 )
{
writer->Update();
}
{
const double origin[
Dimension ] = { 25.0, 35.0 };
filter->SetOutputOrigin( origin );
}
size[0] = 40;
size[1] = 45;
filter->SetSize( size );
{
const double spacing[
Dimension ] = { 4.0, 4.5 };
filter->SetOutputSpacing( spacing );
}
if( exampleAction == 4 )
{
writer->Update();
}
return EXIT_SUCCESS;
}