29 #include <DGtal/base/Common.h>
30 #include <DGtal/helpers/StdDefs.h>
31 #include <DGtal/io/readers/LongvolReader.h>
32 #include <DGtal/io/writers/VolWriter.h>
33 #include <DGtal/images/Image.h>
34 #include <DGtal/images/ImageContainerBySTLVector.h>
35 #include <DGtal/base/BasicFunctors.h>
39 using namespace DGtal;
80 template<
typename TInput>
82 unsigned char operator()(
const TInput& aInput)
const
98 myMin(vmin), myMax(vmax) {}
100 inline unsigned char operator()(
const DGtal::int64_t& aInput)
const
103 (double) (myMax-myMin)));
110 int main(
int argc,
char**argv)
116 std::string inputFileName;
117 std::string outputFileName {
"result.vol"};
118 unsigned int mode {0};
120 app.description(
"Converts a longvol (long int) to a vol file (unsigned char). \n Basic example:\n\t longvol2vol --input <LongvolFileName> --o <VolOutputFileName> ");
121 app.add_option(
"-i,--input,1", inputFileName,
"Input longvol filename ( .longvol)" )
123 ->check(CLI::ExistingFile);
124 app.add_option(
"-o,--output,2",outputFileName,
"Output vol filename." );
125 app.add_option(
"-m,--mode", mode,
"Conversion mode:\n\t 0 = cast (default)\n\t 1 = Linear Scaling\n\t 2 = Grayscale cycle (32 steps, except 0 values).")
126 -> check(CLI::IsMember({0, 1, 2}));
129 app.get_formatter()->column_width(40);
130 CLI11_PARSE(app, argc, argv);
145 vmax = *std::max_element(imageC.begin(), imageC.end());
146 vmin = *std::min_element(imageC.begin(), imageC.end());
147 trace.
info() <<
"Max value = "<< vmax<<std::endl;
148 trace.
info() <<
"Min value = "<< vmin<<std::endl;
159 trace.
error()<<
"Error while exporting the Vol.";
int main(int argc, char **argv)
Trace trace(traceWriterTerm)
static ImageContainer importLongvol(const std::string &filename, const Functor &aFunctor=Functor())
static DGtal::int64_t castToInt64_t(const T &aT)
static double castToDouble(const T &aT)
static bool exportVol(const std::string &filename, const Image &aImage, const Functor &aFunctor=Functor())