32 #include "DGtal/base/Common.h"
33 #include "DGtal/helpers/StdDefs.h"
34 #include "DGtal/images/ImageContainerBySTLVector.h"
35 #include "DGtal/io/writers/GenericWriter.h"
40 using namespace DGtal;
79 int main(
int argc,
char** argv )
86 std::string outputFileName {
"result.vol"};
90 int foregroundVal {128};
91 int backgroundVal {0};
93 std::vector<int> domainCoords;
95 app.description(
"Convert digital set of points into a volumic file.\n Example:\n sdp2vol volumePoints.sdp volume.vol -d 0 0 0 10 10 10 \n");
96 app.add_option(
"-i,--input,1", inputSDP,
"Sequence of 3d Discrete points (.sdp)." )
98 ->check(CLI::ExistingFile);
99 app.add_option(
"-o,--output,2", outputFileName,
"Vol file (.vol, .longvol, .pgm3d) ");
100 app.add_option(
"-f,--foregroundVal", foregroundVal,
"value which will represent the foreground object in the resulting image (default 128)");
101 app.add_option(
"-b,--backgroundVal", backgroundVal,
"value which will represent the background outside the object in the resulting image (default 0)");
102 app.add_option(
"-d,--domain", domainCoords,
"customizes the domain of the resulting image xmin ymin zmin xmax ymax zmax (computed automatically by default)")
105 app.add_flag(
"--invertY", invertY,
"Invert the Y axis (image flip in the y direction)");
108 app.get_formatter()->column_width(40);
109 CLI11_PARSE(app, argc, argv);
112 vector<unsigned int> vPos;
116 trace.
info() <<
"Reading input SDP file: " << inputSDP ;
118 trace.
info() <<
" [done] " << std::endl ;
125 explicit BBCompPoints(
unsigned int d): myDim(d){};
129 if(domainCoords.size() != 6 )
131 unsigned int marge = 1;
132 for(
unsigned int i=0; i< 3; i++)
134 BBCompPoints cmp_points(i);
135 ptUpper[i] = (*(std::max_element(vectPoints.begin(), vectPoints.end(), cmp_points)))[i]+marge;
136 ptLower[i] = (*(std::min_element(vectPoints.begin(), vectPoints.end(), cmp_points)))[i]-marge;
141 ptLower =
Z3i::Point(domainCoords[0],domainCoords[1], domainCoords[2]);
142 ptUpper =
Z3i::Point(domainCoords[3],domainCoords[4], domainCoords[5]);
146 trace.
info() <<
"domain: "<<imageDomain<<std::endl;
147 Image3D imageResult(imageDomain);
149 iter!= imageResult.domain().end();
152 imageResult.setValue(*iter, backgroundVal);
155 for(
unsigned int i=0; i<vectPoints.size(); i++)
159 vectPoints[i][1]=ptUpper[1]-vectPoints[i][1];
161 if(imageResult.domain().isInside(vectPoints[i]))
163 imageResult.setValue(vectPoints[i], foregroundVal);
167 trace.
warning() <<
"point " << vectPoints[i] <<
" outside the domain (ignored in the resulting volumic image)" << std::endl;
170 trace.
info()<<
"Exporting resulting volumic image ... ";
int main(int argc, char **argv)
std::vector< Value >::const_iterator ConstIterator
Trace trace(traceWriterTerm)