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>
41 using namespace DGtal;
93 void missingParam ( std::string param )
95 trace.error() <<
" Parameter: "<<param<<
" is required..";
96 trace.info() <<std::endl;
100 int main(
int argc,
char**argv)
105 std::string inputFileName;
106 std::string outputFileName {
"result.vol"};
113 app.description(
"Apply a linear rescaling of the image intensity from an input intensity interval [InMin, InMax] into an output interval [OutMin, OutMax].\n Basic usage:\n volIntensityScale --input <volFileName> --output <volOutputFileName> (both files can be independently in vol, pgm3D, p3d format)\n Example: \n volIntensityScale ${DGtal}/examples/samples/lobster.vol --inMin 0 --inMax 100 lobster0-100.vol");
115 app.add_option(
"-i,--input,1", inputFileName,
"Input vol file." )
117 ->check(CLI::ExistingFile);
119 app.add_option(
"-o,--output,2",outputFileName,
"volumetric output file (.vol, .pgm, .pgm3d, .longvol) ",
true);
120 app.add_option(
"-m,--inMin", inMin,
"the min value of the input image.",
true);
121 app.add_option(
"-M,--inMax", inMax,
"the max value of the input image.",
true);
122 app.add_option(
"--outMin", outMin,
"the min value of the output image.",
true);
123 app.add_option(
"--outMax", outMax,
"the max value of the output image.",
true);
125 app.get_formatter()->column_width(40);
126 CLI11_PARSE(app, argc, argv);
130 trace.beginBlock(
"Loading file");
132 typedef ImageContainerBySTLVector<Z3i::Domain, unsigned char> MyImageC;
133 typedef DGtal::functors::Rescaling<int ,unsigned char > RescalFCT;
134 MyImageC image = VolReader< MyImageC, RescalFCT >::importVol( inputFileName,
140 trace.beginBlock(
"Exporting...");
141 bool res = GenericWriter<MyImageC>::exportFile(outputFileName, image);
143 if (res)
return 0;
else return 1;