31#include <DGtal/base/Common.h>
32#include <DGtal/io/readers/GenericReader.h>
33#include <DGtal/io/writers/GenericWriter.h>
34#include <DGtal/helpers/StdDefs.h>
35#include <DGtal/images/ImageContainerBySTLVector.h>
36#include <DGtal/images/ConstImageAdapter.h>
96int main(
int argc,
char**argv)
102 std::string inputFileName;
103 std::string outputFileName {
"result.vol"};
104 std::vector<unsigned int> inputVals;
105 std::vector<unsigned int> outputVals;
107 app.description(
"Apply basic vol image transform from the input values to output values.\n Basic usage:\n \t volTrValues --input <volFileName> --o <volOutputFileName> -s 1 99 -r 100 200 \n\t => all voxel of values 1 (resp. 99) will be 100 (resp. 200) in the resulting image.");
109 app.add_option(
"-i,--input,1", inputFileName,
"Input vol file." )
111 ->check(CLI::ExistingFile);
113 app.add_option(
"--output,-o,2",outputFileName,
"Output filename.");
114 app.add_option(
"--inputVals,-s", inputVals,
"specify the values which will be transformed with the output values (given with --outputVals).") ->required();
115 app.add_option(
"--outputVals,-r", outputVals,
"specify the values which will be transformed with the output values (given with --outputVals).") ->required();
118 app.get_formatter()->column_width(40);
119 CLI11_PARSE(app, argc, argv);
123 if(inputVals.size()!=outputVals.size()){
124 trace.error()<<
"Transformation not possible the two sets of input/output values should have the same size." << std::endl;
128 trace.beginBlock(
"Loading file");
129 typedef ImageContainerBySTLVector<Z3i::Domain, unsigned char> MyImageC;
130 MyImageC image = GenericReader< MyImageC >::import( inputFileName );
133 for(MyImageC::Domain::ConstIterator it = image.domain().begin(),
134 itend = image.domain().end(); it != itend; ++it)
137 for(
unsigned int i = 0; i< inputVals.size(); i++){
138 if(inputVals.at(i)==val){
139 image.setValue( *it , outputVals.at(i));
144 trace.beginBlock(
"Exporting...");
145 bool res = GenericWriter<MyImageC>::exportFile(outputFileName, image);
148 if (res)
return 0;
else return 1;