32 #include "DGtal/base/Common.h"
33 #include "DGtal/helpers/StdDefs.h"
34 #include "DGtal/images/ImageContainerBySTLVector.h"
35 #include "DGtal/io/readers/GenericReader.h"
41 using namespace DGtal;
91 int main(
int argc,
char** argv )
94 std::string inputFilename;
95 std::string outputFilename {
"result.sdp"};
96 bool exportImageValues {
false};
97 int thresholdMin {128};
98 int thresholdMax {255};
104 app.description(
"Convert volumetric file into a digital set of points from a given threshold.\n vol2sdp -i ${DGtal}/examples/samples/lobster.vol -o volumeList.sdp");
105 app.add_option(
"-i,--input,1", inputFilename,
"vol file (.vol, .longvol .p3d, .pgm3d and if WITH_ITK is selected: dicom, dcm, mha, mhd) or sdp (sequence of discrete points). 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,
"sequence of discrete point file (.sdp)",
true);
109 app.add_flag(
"--exportImageValues,-e",exportImageValues,
"option to export also the image value of the voxel in a fourth field.");
110 app.add_option(
"--thresholdMin,-m", thresholdMin,
"threshold min (excluded) to define binary shape.",
true);
111 app.add_option(
"--thresholdMax,-M", thresholdMax,
"threshold max (included) to define binary shape.",
true);
112 app.add_option(
"--rescaleInputMin", rescaleInputMin,
"min value used to rescale the input intensity (to avoid basic cast into 8 bits image).",
true);
113 app.add_option(
"--rescaleInputMax", rescaleInputMax,
"max value used to rescale the input intensity (to avoid basic cast into 8 bits image).",
true);
115 app.get_formatter()->column_width(40);
116 CLI11_PARSE(app, argc, argv);
121 RescalFCT(rescaleInputMin,
124 trace.
info() <<
" [done] " << std::endl ;
125 std::ofstream outStream;
126 outStream.open(outputFilename.c_str());
128 trace.
info() <<
"Processing image to output file " << outputFilename ;
130 outStream <<
"# sdp file generate by vol2sdp with source vol:" << inputFilename
131 <<
" and threshold min: " << thresholdMin <<
" max:" << thresholdMax << std::endl;
132 outStream <<
"# format: x y z ";
133 if(exportImageValues){
134 outStream <<
" image_value";
136 outStream << std::endl;
139 if(inputImage(*it) >= thresholdMin && inputImage(*it) <= thresholdMax ){
140 outStream << (*it)[0] <<
" " << (*it)[1] <<
" " << (*it)[2];
141 if(exportImageValues){
142 outStream <<
" " << (
unsigned int) inputImage(*it);
145 outStream << std::endl;
149 trace.
info() <<
" [done] " << std::endl ;
int main(int argc, char **argv)
const Domain & domain() const
std::vector< Value >::const_iterator ConstIterator
Trace trace(traceWriterTerm)