32 #include <QImageReader>
34 #include "DGtal/io/viewers/Viewer3D.h"
35 #include "DGtal/io/DrawWithDisplay3DModifier.h"
36 #include "DGtal/io/Color.h"
37 #include "DGtal/shapes/Shapes.h"
38 #include "DGtal/helpers/StdDefs.h"
39 #include "DGtal/io/readers/PointListReader.h"
41 #include "DGtal/io/readers/GenericReader.h"
42 #include "DGtal/images/imagesSetsUtils/SetFromImage.h"
43 #include "DGtal/images/SimpleThresholdForegroundPredicate.h"
44 #include "DGtal/images/ImageSelector.h"
48 #include "DGtal/geometry/volumes/distance/DistanceTransformation.h"
53 using namespace DGtal;
107 void missingParam ( std::string param )
109 trace.
error() <<
" Parameter: "<<param<<
" is required..";
115 int main(
int argc,
char** argv )
119 std::string inputFileName;
120 std::string exportSDPName;
121 std::string fixedPointSDPName;
125 std::vector<int> vectFixedPoints;
127 app.description(
"Applies an homotopic thinning of a 3d image file (vol,longvol,pgm3d...) with 3D viewer. \n Basic usage: \t homotopicThinning3d [options] --input <3dImageFileName> {vol,longvol,pgm3d...} \n Usage by forcing point to be left by the thinning: \n homotopicThinning3D --input ${DGtal}/examples/samples/Al.100.vol --fixedPoints 56 35 5 56 61 5 57 91 38 58 8 38 45 50 97 \n");
128 app.add_option(
"-i,--input,1", inputFileName,
"Input volumetric file (.vol, .pgm3d or p3d)" )
130 ->check(CLI::ExistingFile);
131 app.add_option(
"--min,-m", min,
"Minimum (excluded) value for threshold.",
true);
132 app.add_option(
"--max,-M", max,
"Maximum (included) value for threshold.",
true);
133 app.add_option(
"--exportSDP,-e",exportSDPName,
"Export the resulting set of points in a simple (sequence of discrete point (sdp)).");
134 app.add_option(
"--fixedPoints",vectFixedPoints,
"defines the coordinates of points which should not be removed.");
135 app.add_option(
"--fixedPointSDP,-s",fixedPointSDPName,
"use fixed points from a file.")
136 ->check(CLI::ExistingFile);
139 app.get_formatter()->column_width(40);
140 CLI11_PARSE(app, argc, argv);
149 Predicate aPredicate(image, min, max );
162 if(vectFixedPoints.size() > 0){
163 if(vectFixedPoints.size()%3==0){
164 for(
unsigned int i=0; i < vectFixedPoints.size()-2; i=i+3)
166 Z3i::Point pt(vectFixedPoints.at(i), vectFixedPoints.at(i+1), vectFixedPoints.at(i+2));
167 fixedSet.insertNew(pt);
172 trace.
error()<<
" The coordinates should be 3d coordinates, ignoring fixedPoints option." << std::endl;
176 if(fixedPointSDPName !=
"")
195 std::queue<DigitalSet::Iterator> Q;
198 trace.
info() <<
"Layer: "<< layer << std::endl;
207 if (dt( *it ) <= layer)
209 if ( shape.isSimple( *it ) )
215 while ( ! Q.empty() )
219 if ( shape.isSimple( *it ) && fixedSet.find(*it) == fixedSet.end() )
225 trace.
info() <<
"Nb simple points : "<<nb_simple<<
" " << std::endl;
228 while ( nb_simple != 0 );
233 trace.
info() <<
"Skeleton--> "<<S<<std::endl;
236 QApplication application(argc,argv);
238 viewer.setWindowTitle(
"homotopicThinning3D");
241 viewer <<
SetMode3D( shape_set.className(),
"Paving" );
246 viewer <<
SetMode3D( shape_set.className(),
"PavingTransp" );
249 viewer<< Viewer3D<>::updateDisplay;
251 if (exportSDPName !=
"")
254 out.open(exportSDPName.c_str());
257 out << p[0] <<
" " << p[1] <<
" " << p[2] << std::endl;
260 return application.exec();
int main(int argc, char **argv)
ConstIterator begin() const
Container::iterator Iterator
Size erase(const Point &p)
ConstIterator end() const
const Domain & domain() const
void beginBlock(const std::string &keyword="")
void progressBar(const double currentValue, const double maximalValue)
Trace trace(traceWriterTerm)