int main( int argc, char * argv[] )
{
if( argc < 3 )
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " inputImageFile outputImageFile" << std::endl;
return EXIT_FAILURE;
}
const unsigned int Dimension = 2;
typedef unsigned char PixelComponentType;
ReaderType::Pointer reader = ReaderType::New();
WriterType::Pointer writer = WriterType::New();
reader->SetFileName( argv[1] );
writer->SetFileName( argv[2] );
ImageType, ImageType > FilterType;
FilterType::Pointer filter = FilterType::New();
ImageType, double > InterpolatorType;
InterpolatorType::Pointer interpolator = InterpolatorType::New();
filter->SetInterpolator( interpolator );
TransformType::Pointer transform = TransformType::New();
filter->SetTransform( transform );
PixelType defaultValue;
defaultValue.Fill(50);
filter->SetDefaultPixelValue( defaultValue );
ImageType::SpacingType spacing;
spacing[0] = .5;
spacing[1] = .5;
filter->SetOutputSpacing( spacing );
ImageType::PointType origin;
origin[0] = 30.0;
origin[1] = 40.0;
filter->SetOutputOrigin( origin );
ImageType::DirectionType direction;
direction.SetIdentity();
filter->SetOutputDirection( direction );
ImageType::SizeType size;
size[0] = 300;
size[1] = 300;
filter->SetSize( size );
filter->SetInput( reader->GetOutput() );
writer->SetInput( filter->GetOutput() );
try
{
writer->Update();
}
{
std::cerr << "Exception thrown " << std::endl;
std::cerr << excp << std::endl;
}
return EXIT_SUCCESS;
}