29 #include <DGtal/base/Common.h>
30 #include <DGtal/io/readers/VolReader.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;
89 void missingParam ( std::string param )
91 trace.
error() <<
" Parameter: "<<param<<
" is required..";
97 int main(
int argc,
char**argv)
101 po::options_description general_opt (
"Allowed options are " );
102 general_opt.add_options()
103 (
"help,h",
"display this message." )
104 (
"input,i", po::value<std::string>(),
"Input vol file." )
105 (
"output,o", po::value<string>(),
"Output filename." );
107 po::variables_map vm;
109 po::store(po::parse_command_line(argc, argv, general_opt), vm);
110 }
catch(
const std::exception& ex){
112 trace.
info()<<
"Error checking program options: "<< ex.what()<< endl;
115 if ( !parseOK || vm.count (
"help" ) ||argc<=1 )
117 trace.
info() <<
"Add a border of one voxel with value 0 around a vol file."<<std::endl
118 << std::endl <<
"Basic usage: "<<std::endl
119 <<
"\tvolAddBorder --input <volFileName> --o <volOutputFileName> "<<std::endl
120 << general_opt <<
"\n"
121 <<
"Example: \n \t volAddBorder -i $DGtal/examples/samples/Al.100.vol -o Al.100border.vol";
126 if ( ! ( vm.count (
"input" ) ) ) missingParam (
"--input" );
127 std::string filename = vm[
"input"].as<std::string>();
128 if ( ! ( vm.count (
"output" ) ) ) missingParam (
"--output" );
129 std::string outputFileName = vm[
"output"].as<std::string>();
138 for(MyImageC::Domain::ConstIterator it = imageC.domain().begin(),
139 itend = imageC.domain().end(); it != itend; ++it)
140 outputImage.setValue( *it , imageC(*it));
144 if (res)
return 0;
else return 1;
static Self diagonal(Component val=1)
Trace trace(traceWriterTerm)