30#include <DGtal/base/Common.h>
31#include <DGtal/io/readers/GenericReader.h>
32#include <DGtal/io/writers/RawWriter.h>
33#include <DGtal/helpers/StdDefs.h>
34#include <DGtal/images/Image.h>
35#include <DGtal/images/ImageContainerBySTLVector.h>
87void missingParam ( std::string param )
89 trace.error() <<
" Parameter: "<<param<<
" is required..";
90 trace.info() <<std::endl;
95int main(
int argc,
char**argv)
100 std::string inputFileName;
101 std::string outputFileName {
"result.raw"};
102 DGtal::int64_t rescaleInputMin {0};
103 DGtal::int64_t rescaleInputMax {255};
105 app.description(
"Convert a vol to a 8-bit raw file.\n Example: vol2raw ${DGtal}/examples/samples/lobster.vol res.raw \n");
106 app.add_option(
"-i,--input,1", inputFileName,
"vol file (.vol, .longvol .p3d, .pgm3d and if DGTAL_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." )
108 ->check(CLI::ExistingFile);
109 app.add_option(
"--output,-o,2",outputFileName ,
"output file (.raw).");
110 app.add_option(
"--rescaleInputMin", rescaleInputMin,
"min value used to rescale the input intensity (to avoid basic cast into 8 bits image).");
111 app.add_option(
"--rescaleInputMax", rescaleInputMax,
"max value used to rescale the input intensity (to avoid basic cast into 8 bits image).");
114 app.get_formatter()->column_width(40);
115 CLI11_PARSE(app, argc, argv);
119 typedef ImageContainerBySTLVector<Z3i::Domain, unsigned char> MyImageC;
120 typedef DGtal::functors::Rescaling<DGtal::int64_t ,unsigned char > RescalFCT;
121 MyImageC imageC = GenericReader< MyImageC >::importWithValueFunctor( inputFileName ,RescalFCT(rescaleInputMin,
125 bool res = RawWriter< MyImageC >::exportRaw8(outputFileName, imageC);
126 trace.info() <<
"Raw export done, image dimensions: " << imageC.domain().upperBound()[0]-imageC.domain().lowerBound()[0]+1
127 <<
" " << imageC.domain().upperBound()[1]-imageC.domain().lowerBound()[1]+1
128 <<
" " << imageC.domain().upperBound()[2]-imageC.domain().lowerBound()[2]+1 << std::endl;