29 #include <DGtal/base/Common.h>
30 #include <DGtal/io/readers/VolReader.h>
31 #include <DGtal/io/writers/VolWriter.h>
32 #include "DGtal/io/writers/GenericWriter.h"
33 #include <DGtal/helpers/StdDefs.h>
34 #include <DGtal/images/ImageContainerBySTLVector.h>
35 #include <DGtal/images/ConstImageAdapter.h>
36 #include <boost/program_options/options_description.hpp>
37 #include <boost/program_options/parsers.hpp>
38 #include <boost/program_options/variables_map.hpp>
42 using namespace DGtal;
45 namespace po = boost::program_options;
93 void missingParam ( std::string param )
95 trace.
error() <<
" Parameter: "<<param<<
" is required..";
100 int main(
int argc,
char**argv)
104 po::options_description general_opt (
"Allowed options are: " );
105 general_opt.add_options()
106 (
"help,h",
"display this message." )
107 (
"input,i", po::value<std::string>(),
"Input vol file." )
108 (
"output,o", po::value<std::string>(),
"volumetric output file (.vol, .pgm, .pgm3d, .longvol) " )
109 (
"inMin,m", po::value<int>()->default_value(0),
"the min value of the input image." )
110 (
"inMax,M", po::value<int>()->default_value(255),
"the max value of the input image." )
111 (
"outMin", po::value<int>()->default_value(0),
"the min value of the output image." )
112 (
"outMax", po::value<int>()->default_value(255),
"the max value of the output image." );
115 po::variables_map vm;
118 po::store ( po::parse_command_line ( argc, argv, general_opt ), vm );
119 }
catch(
const std::exception& ex){
121 trace.
info()<<
"Error checking program options: "<< ex.what()<< endl;
124 if (parseOK && ! ( vm.count (
"input" ) ) ) {parseOK=
false; missingParam (
"--input" );};
125 if (parseOK && ! ( vm.count (
"output" ) ) ) {parseOK=
false; missingParam (
"--output" );};
129 if (!parseOK || vm.count (
"help" ))
131 trace.
info() <<
"Apply a linear rescaling of the image intensity from an input intensity interval [InMin, InMax] into an output interval [OutMin, OutMax]." <<std::endl
132 << std::endl <<
"Basic usage: "<<std::endl
133 <<
"\t volIntensityScale --input <volFileName> --output <volOutputFileName> (both files can be independently in vol, pgm3D, p3d format)"<<std::endl
134 << general_opt <<
"\n";
135 std::cout <<
"Example:\n"
136 <<
"volIntensityScale -i ${DGtal}/examples/samples/lobster.vol --inMin 0 --inMax 100 -o lobster0-100.vol \n";
142 std::string filename = vm[
"input"].as<std::string>();
143 std::string outputFileName = vm[
"output"].as<std::string>();
145 int inMin = vm[
"inMin"].as<
int>();
146 int inMax = vm[
"inMax"].as<
int>();
147 int outMin = vm[
"outMin"].as<
int>();
148 int outMax = vm[
"outMax"].as<
int>();
164 if (res)
return 0;
else return 1;
void beginBlock(const std::string &keyword="")
Trace trace(traceWriterTerm)