#include "itkImageFileReader.h" #include "itkImageFileWriter.h" #include "itkImage.h" #include "itkImageIOFactory.h" #include "itkMINC2ImageIOFactory.h" #include "itkMINC2ImageIO.h" namespace { typedef signed short PixelType; const unsigned int Dimension = 3; typedef itk::Image ImageType; typedef itk::ImageFileReader ReaderType; typedef itk::ImageFileWriter WriterType; typedef itk::MINC2ImageIO ImageIOType; } int main(int argc, char ** argv) { // Verify the number of parameters in the command line if ( argc < 3 ) { std::cerr << "Usage: " << std::endl; std::cerr << argv[0] << " inputImageFile outputImageFile " << std::endl; return EXIT_FAILURE; } ReaderType::Pointer reader = ReaderType::New(); ImageIOType::Pointer minc2ImageIO = ImageIOType::New(); reader->SetImageIO(minc2ImageIO); const char* inputFilename = argv[1]; reader->SetFileName(inputFilename); try { reader->Update(); } catch(itk::ExceptionObject& err) { std::cerr << "ExceptionObject caught !" << std::endl; std::cerr << err << std::endl; return EXIT_FAILURE; } WriterType::Pointer writer = WriterType::New(); writer->SetImageIO(minc2ImageIO); const char* outputFilename = argv[2]; writer->SetFileName(outputFilename); writer->SetInput(reader->GetOutput()); try { writer->Update(); } catch(itk::ExceptionObject& err) { std::cerr << "ExceptionObject caught !" << std::endl; std::cerr << err << std::endl; return EXIT_FAILURE; } return EXIT_SUCCESS; }