DGtalTools  1.5.beta
HDF52vol.cpp
1 
28 #include <iostream>
29 #include <DGtal/base/Common.h>
30 #include <DGtal/io/readers/HDF5Reader.h>
31 #include <DGtal/io/writers/VolWriter.h>
32 #include <DGtal/helpers/StdDefs.h>
33 #include <DGtal/images/Image.h>
34 #include <DGtal/images/ImageContainerBySTLVector.h>
35 
36 #include "CLI11.hpp"
37 
38 
39 using namespace std;
40 using namespace DGtal;
41 using namespace Z3i;
42 
43 
78 void missingParam ( std::string param )
79 {
80  trace.error() <<" Parameter: "<<param<<" is required..";
81  trace.info() <<std::endl;
82  exit ( 1 );
83 }
84 
85 
86 int main(int argc, char**argv)
87 {
88 
89 // parse command line using CLI ----------------------------------------------
90  CLI::App app;
91  std::string inputFileName;
92  std::string outputFileName {"result.vol"};
93 
94  app.description("Convert a 3D 8-bit HDF5 file to vol.");
95  app.add_option("-i,--input,1", inputFileName, "Input HDF5 file." )
96  ->required()
97  ->check(CLI::ExistingFile);
98  app.add_option("-o,--output,2", outputFileName, "Output vol filename.", true );
99 
100  app.get_formatter()->column_width(40);
101  CLI11_PARSE(app, argc, argv);
102  // END parse command line using CLI ----------------------------------------------
103 
105 
106  MyImageC imageC = HDF5Reader< MyImageC >::importHDF5_3D( inputFileName, "/UInt8Array3D" );
107  bool res = VolWriter< MyImageC>::exportVol(outputFileName, imageC);
108 
109  if (res)
110  return EXIT_SUCCESS;
111  else
112  {
113  trace.error()<< "Error while exporting the volume."<<std::endl;
114  return EXIT_FAILURE;
115  }
116 }
int main(int argc, char **argv)
std::ostream & error()
std::ostream & info()
Trace trace(traceWriterTerm)