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"
44 using namespace DGtal;
79 int main(
int argc,
char** argv )
81 typedef ImageContainerBySTLVector < Z3i::Domain, unsigned char > Image3D;
85 std::string inputFileName;
86 std::string outputFileName {
"result.raw"};
87 DGtal::int64_t dicomMin {-1000};
88 DGtal::int64_t dicomMax {3000};
90 app.description(
"Convert dicom file into a volumetric file (.vol, .longvol .pgm3d).\n Example:\n dicom2vol ${DGtal}/tests/samples/dicomSample/1629.dcm sample.vol --dicomMin 0 --dicomMax 300.");
91 app.add_option(
"-i,--input,1", inputFileName,
"dicom image (.dcm)." )
93 ->check(CLI::ExistingFile);
94 app.add_option(
"-o,--output,2", outputFileName,
"volumetric file (.vol, .longvol .pgm3d, .raw)",
true);
95 app.add_option(
"--dicomMin",dicomMin,
"set minimum density threshold on Hounsfield scale" );
96 app.add_option(
"--dicomMax",dicomMax,
"set maximum density threshold on Hounsfield scale" );
98 app.get_formatter()->column_width(40);
99 CLI11_PARSE(app, argc, argv);
102 typedef DGtal::functors::Rescaling<int ,unsigned char > RescalFCT;
104 trace.info() <<
"Reading input dicom file " << inputFileName ;
105 Image3D inputImage = DicomReader< Image3D, RescalFCT >::importDicom(inputFileName,
106 RescalFCT(dicomMin,dicomMax, 0, 255) );
107 trace.info() <<
" [done] " << std::endl ;
108 trace.info() <<
" converting into vol file... " ;
109 inputImage >> outputFileName;
110 trace.info() <<
" [done] " << std::endl ;