14 #include "itkImageFileWriter.h" 15 #include "itkImageIOBase.h" 16 #include "itkVectorImage.h" 20 #include "itkImageRegionIterator.h" 21 #include "itkImageRegionConstIterator.h" 22 #include "SparseToVectorImageConverterCLP.h" 25 main(
int argc,
char *argv[])
30 typedef double PixelType;
32 typedef itk::VectorImage<PixelType, 3> OutputImageType;
35 InputImageType::Pointer inputImage;
36 OutputImageType::Pointer outputImage = OutputImageType::New();
37 ReaderType::Pointer reader = ReaderType::New();
40 OutputImageWriterType::Pointer writer = OutputImageWriterType::New();
43 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 outputImage->CopyInformation(inputImage);
61 outputImage->SetRegions(inputImage->GetLargestPossibleRegion());
62 outputImage->Allocate();
65 itk::ImageRegionConstIterator<InputImageType> inputIt(inputImage, inputImage->GetLargestPossibleRegion() );
68 itk::ImageRegionIterator<OutputImageType> outputIt(outputImage, inputImage->GetLargestPossibleRegion() );
74 while( !inputIt.IsAtEnd() )
76 outputIt.Set(inputIt.Get());
83 if (_OutputFileArg.isSet())
85 reader->UpdateOutputInformation();
86 itk::ImageIOBase::Pointer inputImageIOBase = reader->GetImageIO();
87 inputImageIOBase->ReadImageInformation();
88 itk::ImageIOBase::IOComponentType inputImageComponentType =
89 inputImageIOBase->GetComponentType();
93 std::cout <<
"Writing file: " << _OutputFile << std::endl;
94 writer->SetFileName( _OutputFile );
95 writer->SetInput( outputImage );
96 writer->SetComponentType( inputImageComponentType );
99 catch ( itk::ExceptionObject & err )
101 std::cerr <<
"ExceptionObject caught!" << std::endl;
102 std::cerr << err << std::endl;
Writes image data, after casting, to a single file.
int main(int argc, char *argv[])
Reads sparse image data from key and value files.
An n-dimensional vector image with a sparse memory model.