18 #include "itkImageFileWriter.h" 19 #include "itkImageFileReader.h" 21 #include "itkImageIOBase.h" 22 #include "VectorTo4DImageConverterCLP.h" 27 main(
int argc,
char *argv[])
33 typedef double PixelType;
35 typedef itk::Image<PixelType, 4> MultiVolumeImageType;
36 typedef itk::ImageFileReader<VectorImageType> ReaderType;
39 VectorImageType::Pointer inputImage;
40 MultiVolumeImageType::Pointer outputImage = MultiVolumeImageType::New();
41 WriterType::Pointer writer = WriterType::New();
42 ReaderType::Pointer reader = ReaderType::New();
44 reader->SetFileName(_InputFile);
47 std::cout <<
"Reading file: " << _InputFile << std::endl;
50 catch (itk::ExceptionObject & err)
52 std::cerr <<
"ExceptionObject caught!" << std::endl;
53 std::cerr << err << std::endl;
57 inputImage = reader->GetOutput();
60 ConvertorType::Pointer convertor = ConvertorType::New();
61 convertor->SetInput(inputImage);
62 outputImage = convertor->GetOutput();
66 reader->UpdateOutputInformation();
67 itk::ImageIOBase::Pointer inputImageIOBase = reader->GetImageIO();
68 inputImageIOBase->ReadImageInformation();
69 itk::ImageIOBase::IOComponentType inputComponentType =
70 inputImageIOBase->GetComponentType();
74 std::cout <<
"Writing file: " << _OutputFile << std::endl;
75 writer->SetFileName( _OutputFile );
76 writer->SetInput( outputImage );
77 writer->SetComponentType( inputComponentType );
80 catch ( itk::ExceptionObject & err )
82 std::cerr <<
"ExceptionObject caught!" << std::endl;
83 std::cerr << err << std::endl;
int main(int argc, char *argv[])
convert VectorImage<TOutputPixelType, VImageDimension> to Image<TInputPixelType, VImageDimension+1> ...
Writes image data, after casting, to a single file.
itk::VectorImage< ScalarType, 3 > VectorImageType