29 #include <DGtal/base/Common.h>
30 #include <DGtal/io/readers/GenericReader.h>
31 #include <DGtal/io/writers/RawWriter.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;
85 void missingParam ( std::string param )
87 trace.
error() <<
" Parameter: "<<param<<
" is required..";
93 int main(
int argc,
char**argv)
97 po::options_description general_opt (
"Allowed options are: " );
98 general_opt.add_options()
99 (
"help,h",
"display this message." )
100 (
"input,i", po::value<std::string>(),
"vol file (.vol, .longvol .p3d, .pgm3d and if WITH_ITK is selected: dicom, dcm, mha, mhd). For longvol, dicom, dcm, mha or mhd formats, the input values are linearly scaled between 0 and 255." )
101 (
"output,o", po::value<string>(),
"Output filename." )
102 (
"rescaleInputMin", po::value<DGtal::int64_t>()->default_value(0),
"min value used to rescale the input intensity (to avoid basic cast into 8 bits image).")
103 (
"rescaleInputMax", po::value<DGtal::int64_t>()->default_value(255),
"max value used to rescale the input intensity (to avoid basic cast into 8 bits image).");
105 po::variables_map vm;
107 po::store(po::parse_command_line(argc, argv, general_opt), vm);
108 }
catch(
const std::exception& ex){
110 trace.
info()<<
"Error checking program options: "<< ex.what()<< endl;
113 if (!parseOK || vm.count (
"help" ) ||argc<=1 )
115 trace.
info() <<
"Convert a vol to a 8-bit raw file."<<std::endl
116 << std::endl <<
"Basic usage: "<<std::endl
117 <<
"\tvol2raw --input <volFileName> --o <RawOutputFileName> "<<std::endl
118 << general_opt <<
"\n";
123 if ( ! ( vm.count (
"input" ) ) ) missingParam (
"--input" );
124 std::string filename = vm[
"input"].as<std::string>();
125 if ( ! ( vm.count (
"output" ) ) ) missingParam (
"--output" );
126 std::string outputFileName = vm[
"output"].as<std::string>();
139 trace.
info() <<
"Raw export done, image dimensions: " << imageC.domain().upperBound()[0]-imageC.domain().lowerBound()[0]+1
140 <<
" " << imageC.domain().upperBound()[1]-imageC.domain().lowerBound()[1]+1
141 <<
" " << imageC.domain().upperBound()[2]-imageC.domain().lowerBound()[2]+1 << std::endl;
143 if (res)
return 0;
else return 1;
Trace trace(traceWriterTerm)