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;
}
using PixelComponentType = unsigned char;
ReaderType::Pointer reader = ReaderType::New();
WriterType::Pointer writer = WriterType::New();
reader->SetFileName(argv[1]);
writer->SetFileName(argv[2]);
FilterType::Pointer filter = FilterType::New();
using 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);
origin[0] = 30.0;
origin[1] = 40.0;
filter->SetOutputOrigin(origin);
filter->SetOutputDirection(direction);
size[0] = 300;
size[1] = 300;
filter->SetInput(reader->GetOutput());
writer->SetInput(filter->GetOutput());
try
{
writer->Update();
}
catch (const itk::ExceptionObject & excp)
{
std::cerr << "Exception thrown " << std::endl;
std::cerr << excp << std::endl;
}
return EXIT_SUCCESS;
}