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>
36 #include <boost/program_options/options_description.hpp>
37 #include <boost/program_options/parsers.hpp>
38 #include <boost/program_options/variables_map.hpp>
41 using namespace DGtal;
44 namespace po = boost::program_options;
75 void missingParam ( std::string param )
77 trace.
error() <<
" Parameter: "<<param<<
" is required..";
83 int main(
int argc,
char**argv)
87 po::options_description general_opt (
"Allowed options are: " );
88 general_opt.add_options()
89 (
"help,h",
"display this message." )
90 (
"input,i", po::value<std::string>(),
"Input HDF5 file." )
91 (
"output,o", po::value<string>(),
"Output vol filename." );
96 po::store(po::parse_command_line(argc, argv, general_opt), vm);
97 }
catch(
const std::exception& ex){
99 trace.
info()<<
"Error checking program options: "<< ex.what()<< endl;
103 if (!parseOK || vm.count (
"help" ) ||argc<=1 )
105 trace.
info() <<
"Convert a 3D 8-bit HDF5 file to vol."<<std::endl
106 << std::endl <<
"Basic usage: "<<std::endl
107 <<
"\tHDF52vol --input <HDF5FileName> --output <VolOutputFileName> "<<std::endl
108 << general_opt <<
"\n";
113 if ( ! ( vm.count (
"input" ) ) ) missingParam (
"--input" );
114 std::string filename = vm[
"input"].as<std::string>();
115 if ( ! ( vm.count (
"output" ) ) ) missingParam (
"--output" );
116 std::string outputFileName = vm[
"output"].as<std::string>();
128 trace.
error()<<
"Error while exporting the volume."<<std::endl;
Trace trace(traceWriterTerm)