DGtal  0.9.2
viewer3D-8bis-2Dimages.cpp
1 
30 #include <iostream>
32 #include "DGtal/base/Common.h"
33 #include "DGtal/io/readers/VolReader.h"
34 #include "DGtal/images/ImageHelper.h"
35 #include "ConfigExamples.h"
36 #include "DGtal/io/viewers/Viewer3D.h"
38 #include "DGtal/kernel/BasicPointFunctors.h"
40 
42 
43 using namespace std;
44 using namespace DGtal;
45 
47 
48 int main( int argc, char** argv )
49 {
50 
54  Image3D::Value, DGtal::functors::Identity > ImageAdapterExtractor;
55 
57  QApplication application(argc,argv);
58  typedef Viewer3D<> MyViewer;
59  MyViewer viewer;
60  viewer.show();
61  std::string inputFilename = examplesPath + "samples/lobster.vol";
62  Image3D imageVol = VolReader<Image3D>::importVol(inputFilename);
64 
65 
66 
68  DGtal::Z3i::Point ptCenter(50, 62, 28);
69  const int IMAGE_PATCH_WIDTH = 20;
70  // Setting the image domain of the resulting image to be displayed in 3D:
71  DGtal::Z2i::Domain domainImage2D (DGtal::Z2i::Point(0,0),
72  DGtal::Z2i::Point(IMAGE_PATCH_WIDTH, IMAGE_PATCH_WIDTH));
74 
75 
76 
77  unsigned int pos=0;
78  for (double alpha = 0; alpha< 1.54; alpha+= 0.01){
80  // Extracting images from 3D embeder
82  ptCenter+DGtal::Z3i::RealPoint(200.0*cos(alpha),100.0*sin(alpha)),
83  DGtal::Z3i::RealPoint(cos(alpha),sin(alpha),cos(2.0*alpha)),
84  IMAGE_PATCH_WIDTH);
85  ImageAdapterExtractor extractedImage(imageVol, domainImage2D, embedder, idV);
87 
89  //Display image and update its position with embeder
90  viewer << extractedImage;
91  viewer << DGtal::UpdateImage3DEmbedding<Z3i::Space, Z3i::KSpace>(pos,
92  embedder(Z2i::RealPoint(0,0)),
93  embedder(Z2i::RealPoint(IMAGE_PATCH_WIDTH,0)),
94  embedder(domainImage2D.upperBound()),
95  embedder(Z2i::RealPoint(0, IMAGE_PATCH_WIDTH)));
97  pos++;
98  }
99 
100 
101  viewer << MyViewer::updateDisplay;
102 
103 
104 return application.exec();
105 
106  trace.endBlock();
107  return 0;
108 }
109 // //
Trace trace
Definition: Common.h:130
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
STL namespace.
double endBlock()
Aim: Define a simple default functor that just returns its argument.
Aim: Functor that embeds a 2D point into a 3D space from two axis vectors and an origin point given i...
Aim: implements methods to read a "Vol" file format.
Definition: VolReader.h:88
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: implements a const image adapter with a given domain (i.e. a subdomain) and 2 functors : g for d...
Space::RealPoint RealPoint
Definition: StdDefs.h:170