29 #include <DGtal/base/Common.h>
30 #include <DGtal/io/readers/RawReader.h>
31 #include <DGtal/io/writers/VolWriter.h>
32 #include <DGtal/io/readers/VolReader.h>
33 #include <DGtal/io/writers/RawWriter.h>
34 #include <DGtal/helpers/StdDefs.h>
35 #include "DGtal/io/colormaps/GrayscaleColorMap.h"
36 #include <DGtal/images/Image.h>
37 #include <DGtal/images/ImageContainerBySTLVector.h>
39 #include <boost/program_options/options_description.hpp>
40 #include <boost/program_options/parsers.hpp>
41 #include <boost/program_options/variables_map.hpp>
44 using namespace DGtal;
47 namespace po = boost::program_options;
81 void missingParam ( std::string param )
83 trace.
error() <<
" Parameter: "<<param<<
" is required..";
89 int main(
int argc,
char**argv)
93 po::options_description general_opt (
"Allowed options are: " );
94 general_opt.add_options()
95 (
"help,h",
"display this message." )
96 (
"input,i", po::value<std::string>(),
"Input raw file." )
97 (
"output,o", po::value<string>(),
"Output vol filename." )
98 (
"x,x", po::value<unsigned int>(),
"x extent." )
99 (
"y,y", po::value<unsigned int >(),
"y extent." )
100 (
"z,z", po::value<unsigned int>(),
"z extent." );
103 po::variables_map vm;
105 po::store(po::parse_command_line(argc, argv, general_opt), vm);
106 }
catch(
const std::exception& ex){
108 trace.
info()<<
"Error checking program options: "<< ex.what()<< endl;
112 if (!parseOK || vm.count (
"help" ) ||argc<=1 )
114 trace.
info() <<
"Converts a 8-bit raw file to vol."<<std::endl
115 << std::endl <<
"Basic usage: "<<std::endl
116 <<
"\traw2vol -x 128 -y 128 -z 128 --input <RawFileName> --output <VolOutputFileName> "<<std::endl
117 << general_opt <<
"\n";
122 if ( ! ( vm.count (
"input" ) ) ) missingParam (
"--input" );
123 std::string filename = vm[
"input"].as<std::string>();
124 if ( ! ( vm.count (
"output" ) ) ) missingParam (
"--output" );
125 std::string outputFileName = vm[
"output"].as<std::string>();
126 if ( ! ( vm.count (
"x" ) ) ) missingParam (
"--x" );
127 unsigned int x = vm[
"x"].as<
unsigned int>();
128 if ( ! ( vm.count (
"y" ) ) ) missingParam (
"--y" );
129 unsigned int y = vm[
"y"].as<
unsigned int>();
130 if ( ! ( vm.count (
"z" ) ) ) missingParam (
"--z" );
131 unsigned int z = vm[
"z"].as<
unsigned int>();
143 trace.
error()<<
"Error while exporting the volume."<<std::endl;
Trace trace(traceWriterTerm)