29 #include <DGtal/base/Common.h>
30 #include <DGtal/io/readers/RawReader.h>
31 #include <DGtal/io/writers/HDF5Writer.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;
79 void missingParam ( std::string param )
81 trace.
error() <<
" Parameter: "<<param<<
" is required..";
87 int main(
int argc,
char**argv)
91 po::options_description general_opt (
"Allowed options are: " );
92 general_opt.add_options()
93 (
"help,h",
"display this message." )
94 (
"input,i", po::value<std::string>(),
"Input raw file." )
95 (
"output,o", po::value<string>(),
"Output HDF5 filename." )
96 (
"x,x", po::value<unsigned int>(),
"x extent." )
97 (
"y,y", po::value<unsigned int >(),
"y extent." )
98 (
"z,z", po::value<unsigned int>(),
"z extent." );
101 po::variables_map vm;
103 po::store(po::parse_command_line(argc, argv, general_opt), vm);
104 }
catch(
const std::exception& ex){
106 trace.
info()<<
"Error checking program options: "<< ex.what()<< endl;
110 if (!parseOK || vm.count (
"help" ) ||argc<=1 )
112 trace.
info() <<
"Converts a 3D 8-bit raw file to HDF5."<<std::endl
113 << std::endl <<
"Basic usage: "<<std::endl
114 <<
"\traw2HDF5 -x 128 -y 128 -z 128 --input <RawFileName> --output <HDF5OutputFileName> "<<std::endl
115 << general_opt <<
"\n";
120 if ( ! ( vm.count (
"input" ) ) ) missingParam (
"--input" );
121 std::string filename = vm[
"input"].as<std::string>();
122 if ( ! ( vm.count (
"output" ) ) ) missingParam (
"--output" );
123 std::string outputFileName = vm[
"output"].as<std::string>();
124 if ( ! ( vm.count (
"x" ) ) ) missingParam (
"--x" );
125 unsigned int x = vm[
"x"].as<
unsigned int>();
126 if ( ! ( vm.count (
"y" ) ) ) missingParam (
"--y" );
127 unsigned int y = vm[
"y"].as<
unsigned int>();
128 if ( ! ( vm.count (
"z" ) ) ) missingParam (
"--z" );
129 unsigned int z = vm[
"z"].as<
unsigned int>();
141 trace.
error()<<
"Error while exporting the HDF5 file."<<std::endl;
Trace trace(traceWriterTerm)