31 #include <QtGui/qapplication.h>
33 #include "DGtal/base/Common.h"
34 #include "DGtal/io/readers/VolReader.h"
35 #include "DGtal/io/viewers/Viewer3D.h"
36 #include "DGtal/io/DrawWithDisplay3DModifier.h"
38 #include "DGtal/io/Color.h"
39 #include "DGtal/io/colormaps/GradientColorMap.h"
40 #include "DGtal/images/ImageSelector.h"
43 #include <boost/program_options/options_description.hpp>
44 #include <boost/program_options/parsers.hpp>
45 #include <boost/program_options/variables_map.hpp>
48 using namespace DGtal;
52 namespace po = boost::program_options;
54 int main(
int argc,
char** argv )
57 po::options_description general_opt(
"Allowed options are: ");
58 general_opt.add_options()
59 (
"help,h",
"display this message")
60 (
"input-file,i", po::value<std::string>(),
"volume file" )
61 (
"thresholdMin,m", po::value<int>()->default_value(0),
"threshold min to define binary shape" )
62 (
"thresholdMax,M", po::value<int>()->default_value(255),
"threshold max to define binary shape" )
63 (
"transparency,t", po::value<uint>()->default_value(255),
"transparency") ;
65 po::store(po::parse_command_line(argc, argv, general_opt), vm);
67 if(vm.count(
"help")||argc<=1)
69 std::cout <<
"Usage: " << argv[0] <<
" [input-file]\n"
70 <<
"Display volume file as a voxel set by using QGLviewer"
71 << general_opt <<
"\n";
75 if(! vm.count(
"input-file"))
77 trace.
error() <<
" The file name was defined" << endl;
80 string inputFilename = vm[
"input-file"].as<std::string>();
81 int thresholdMin = vm[
"thresholdMin"].as<
int>();
82 int thresholdMax = vm[
"thresholdMax"].as<
int>();
83 unsigned char transp = vm[
"transparency"].as<uint>();
85 QApplication application(argc,argv);
87 viewer.setWindowTitle(
"simple Volume Viewer");
93 trace.
info() <<
"Image loaded: "<<image<< std::endl;
97 gradient.addColor(Color::Blue);
98 gradient.addColor(Color::Green);
99 gradient.addColor(Color::Yellow);
100 gradient.addColor(Color::Red);
102 unsigned char val= image( (*it) );
104 Color c= gradient(val);
105 if(val<=thresholdMax && val >=thresholdMin){
111 viewer << Viewer3D::updateDisplay;
112 return application.exec();