int main( int argc, char ** argv )
{
if( argc < 7 )
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " inputImageFile outputImageFile " << std::endl;
std::cerr << " startX startY sizeX sizeY" << std::endl;
return EXIT_FAILURE;
}
typedef signed short InputPixelType;
typedef signed short OutputPixelType;
OutputImageType > FilterType;
FilterType::Pointer filter = FilterType::New();
start[0] = atoi( argv[3] );
start[1] = atoi( argv[4] );
size[0] = atoi( argv[5] );
size[1] = atoi( argv[6] );
OutputImageType::RegionType desiredRegion;
desiredRegion.SetSize( size );
desiredRegion.SetIndex( start );
filter->SetRegionOfInterest( desiredRegion );
ReaderType::Pointer reader = ReaderType::New();
WriterType::Pointer writer = WriterType::New();
const char * inputFilename = argv[1];
const char * outputFilename = argv[2];
reader->SetFileName( inputFilename );
writer->SetFileName( outputFilename );
filter->SetInput( reader->GetOutput() );
writer->SetInput( filter->GetOutput() );
try
{
writer->Update();
}
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}