32 #include "DGtal/base/Common.h"
33 #include "DGtal/helpers/StdDefs.h"
34 #include "DGtal/base/BasicFunctors.h"
35 #include "DGtal/images/ImageContainerBySTLVector.h"
36 #include "DGtal/io/writers/GenericWriter.h"
37 #include "DGtal/io/readers/DicomReader.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;
73 namespace po = boost::program_options;
76 int main(
int argc,
char** argv )
82 po::options_description general_opt(
"Allowed options are: ");
83 general_opt.add_options()
84 (
"help,h",
"display this message")
85 (
"input,i", po::value<std::string>(),
"dicom image (.dcm) " )
86 (
"output,o", po::value<std::string>(),
"volumetric file (.vol, .longvol .pgm3d) " )
87 (
"dicomMin", po::value<int>()->default_value(-1000),
"set minimum density threshold on Hounsfield scale")
88 (
"dicomMax", po::value<int>()->default_value(3000),
"set maximum density threshold on Hounsfield scale");
95 po::store(po::parse_command_line(argc, argv, general_opt), vm);
96 }
catch(
const std::exception& ex){
98 trace.
info()<<
"Error checking program options: "<< ex.what()<< endl;
101 if( !parseOK || vm.count(
"help")||argc<=1)
103 std::cout <<
"Usage: " << argv[0] <<
" [input] [output]\n"
104 <<
"Convert dicom file into a volumetric file (.vol, .longvol .pgm3d) ."
105 << general_opt <<
"\n";
106 std::cout <<
"Example:\n"
107 <<
"dicom2vol -i ${DGtal}/tests/samples/dicomSample/1629.dcm --dicomMin -500 --dicomMax -100 -o sample.vol \n";
111 if(! vm.count(
"input") ||! vm.count(
"output"))
113 trace.
error() <<
" Input and output filename are needed to be defined" << endl;
118 string inputFilename = vm[
"input"].as<std::string>();
119 string outputFilename = vm[
"output"].as<std::string>();
120 int dicomMin = vm[
"dicomMin"].as<
int>();
121 int dicomMax = vm[
"dicomMax"].as<
int>();
124 trace.
info() <<
"Reading input dicom file " << inputFilename ;
126 RescalFCT(dicomMin,dicomMax, 0, 255) );
127 trace.
info() <<
" [done] " << std::endl ;
128 trace.
info() <<
" converting into vol file... " ;
129 inputImage >> outputFilename;
130 trace.
info() <<
" [done] " << std::endl ;
Trace trace(traceWriterTerm)