int main( int argc, char* argv[] )
{
if( argc != 3 )
{
std::cerr << "Usage: "<< std::endl;
std::cerr << argv[0];
std::cerr << " <InputFileName> <OutputFileName>";
std::cerr << std::endl;
return EXIT_FAILURE;
}
const char * inputFileName = argv[1];
const char * outputFileName = argv[2];
std::string format = std::string( outputFileName ) +
std::string( "-%d.png" );
typedef unsigned char PixelType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( inputFileName );
typedef unsigned char OutputPixelType;
RescaleFilterType;
RescaleFilterType::Pointer rescale = RescaleFilterType::New();
rescale->SetInput( reader->GetOutput() );
rescale->SetOutputMinimum( 0 );
rescale->SetOutputMaximum( 255 );
rescale->UpdateLargestPossibleRegion();
InputImageType::RegionType region =
reader->GetOutput()->GetLargestPossibleRegion();
fnames->SetStartIndex( 0 );
fnames->SetEndIndex( size[2] - 1 );
fnames->SetIncrementIndex( 1 );
fnames->SetSeriesFormat( format.c_str() );
WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetInput( rescale->GetOutput() );
writer->SetFileNames( fnames->GetFileNames() );
try
{
writer->Update();
}
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}