14 #include "itkImageFileWriter.h" 15 #include "itkVectorImage.h" 17 #include "itkImageFileReader.h" 19 #include "itkImageRegionIterator.h" 20 #include "itkImageRegionConstIterator.h" 21 #include "VectorToSparseImageConverterCLP.h" 24 main(
int argc,
char *argv[])
29 typedef double PixelType;
30 typedef itk::VectorImage<PixelType, 3> InputImageType;
32 typedef itk::ImageFileReader<InputImageType> ReaderType;
34 InputImageType::Pointer inputImage;
35 OutputImageType::Pointer outputImage = OutputImageType::New();
36 ReaderType::Pointer reader = ReaderType::New();
39 OutputImageWriterType;
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())
87 std::cout <<
"Writing file: " << _OutputFile << std::endl;
88 writer->SetFileName( _OutputFile );
89 writer->SetInput( outputImage );
92 catch ( itk::ExceptionObject & err )
94 std::cerr <<
"ExceptionObject caught!" << std::endl;
95 std::cerr << err << std::endl;
int main(int argc, char *argv[])
Writes sparse vector image data to key and value files.
An n-dimensional vector image with a sparse memory model.