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>
86void missingParam ( std::string param )
88 trace.error() <<
" Parameter: "<<param<<
" is required..";
89 trace.info() <<std::endl;
94int main(
int argc,
char**argv)
99 std::string inputFileName;
100 std::string outputFileName {
"result.raw"};
101 DGtal::int64_t rescaleInputMin {0};
102 DGtal::int64_t rescaleInputMax {255};
104 app.description(
"Convert a vol to a 8-bit raw file.\n Example: vol2raw ${DGtal}/examples/samples/lobster.vol res.raw \n");
105 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." )
107 ->check(CLI::ExistingFile);
108 app.add_option(
"--output,-o,2",outputFileName ,
"output file (.raw).");
109 app.add_option(
"--rescaleInputMin", rescaleInputMin,
"min value used to rescale the input intensity (to avoid basic cast into 8 bits image).");
110 app.add_option(
"--rescaleInputMax", rescaleInputMax,
"max value used to rescale the input intensity (to avoid basic cast into 8 bits image).");
113 app.get_formatter()->column_width(40);
114 CLI11_PARSE(app, argc, argv);
118 typedef ImageContainerBySTLVector<Z3i::Domain, unsigned char> MyImageC;
119 typedef DGtal::functors::Rescaling<DGtal::int64_t ,unsigned char > RescalFCT;
120 MyImageC imageC = GenericReader< MyImageC >::importWithValueFunctor( inputFileName ,RescalFCT(rescaleInputMin,
124 bool res = RawWriter< MyImageC >::exportRaw8(outputFileName, imageC);
125 trace.info() <<
"Raw export done, image dimensions: " << imageC.domain().upperBound()[0]-imageC.domain().lowerBound()[0]+1
126 <<
" " << imageC.domain().upperBound()[1]-imageC.domain().lowerBound()[1]+1
127 <<
" " << imageC.domain().upperBound()[2]-imageC.domain().lowerBound()[2]+1 << std::endl;