DGtal  0.9.3
test3DImageViewEmbedder.cpp
Go to the documentation of this file.
1 
30 #include <iostream>
32 #include "DGtal/base/Common.h"
33 #include "DGtal/io/viewers/Viewer3D.h"
34 #include "DGtal/helpers/StdDefs.h"
35 #include "DGtal/io/readers/GenericReader.h"
36 #include "DGtal/io/writers/GenericWriter.h"
37 #include "DGtal/kernel/BasicPointFunctors.h"
38 #include "DGtal/images/ConstImageAdapter.h"
39 #include "DGtal/io/viewers/DrawWithViewer3DModifier.h"
40 #include "ConfigTest.h"
41 
42 #include <limits>
44 
45 using namespace std;
46 using namespace DGtal;
47 using namespace Z3i;
48 
49 
50 
51 
53 // Functions for testing class Viewer3D.
55 
56 
57 
59 // Standard services - public :
60 
61 int main( int argc, char** argv )
62 {
63 
66  Image3D::Value, DGtal::functors::Identity > ImageAdapterExtractor;
67 
68  QApplication application(argc,argv);
69  Viewer3D<> viewer;
70  viewer.setWindowTitle("simpleViewer");
71  viewer.show();
72 
73  trace.beginBlock("Testing Viewer with Image Embedder ");
74  Point pcenter( 10, 20, 20 );
75  Point pcenterImg( 10, 20, 20 );
76 
77  std::string filename = testPath + "samples/cat10.pgm3d";
78  Image3D image = DGtal::GenericReader<Image3D>::import(filename);
79 
80  const int IMAGE_PATCH_WIDTH = 80;
81  // Setting the image domain of the resulting image to be displayed in 3D:
82  DGtal::Z2i::Domain domainImage2D (DGtal::Z2i::Point(0,0),
83  DGtal::Z2i::Point(IMAGE_PATCH_WIDTH, IMAGE_PATCH_WIDTH));
84 
86  pcenterImg, Z3i::RealPoint(1, 1, 1),
89  pcenterImg, Z3i::RealPoint(1, 0, 0),
92  pcenterImg, Z3i::RealPoint(0, 1, 0 ),
95  pcenterImg, Z3i::RealPoint(0, 0, 1 ),
97 
99  ImageAdapterExtractor extractedImage(image, domainImage2D, embedder, idV);
100  ImageAdapterExtractor extractedImage2(image, domainImage2D, embedder2, idV);
101  ImageAdapterExtractor extractedImage3(image, domainImage2D, embedder3, idV);
102  ImageAdapterExtractor extractedImage4(image, domainImage2D, embedder4, idV);
103 
104  viewer << extractedImage;
105  viewer << extractedImage2;
106  viewer << extractedImage3;
107  viewer << extractedImage4;
108  viewer << DGtal::UpdateImage3DEmbedding<Z3i::Space, Z3i::KSpace>(0,
109  embedder(Z2i::RealPoint(0,0),false),
110  embedder(Z2i::RealPoint(IMAGE_PATCH_WIDTH,0),false),
111  embedder(domainImage2D.upperBound(), false),
112  embedder(Z2i::RealPoint(0, IMAGE_PATCH_WIDTH), false));
113  viewer << DGtal::UpdateImage3DEmbedding<Z3i::Space, Z3i::KSpace>(1,
114  embedder2(Z2i::RealPoint(0,0),false),
115  embedder2(Z2i::RealPoint(IMAGE_PATCH_WIDTH,0),false),
116  embedder2(domainImage2D.upperBound(), false),
117  embedder2(Z2i::RealPoint(0, IMAGE_PATCH_WIDTH), false));
118  viewer << DGtal::UpdateImage3DEmbedding<Z3i::Space, Z3i::KSpace>(2,
119  embedder3(Z2i::RealPoint(0,0),false),
120  embedder3(Z2i::RealPoint(IMAGE_PATCH_WIDTH,0),false),
121  embedder3(domainImage2D.upperBound(), false),
122  embedder3(Z2i::RealPoint(0, IMAGE_PATCH_WIDTH), false));
123  viewer << DGtal::UpdateImage3DEmbedding<Z3i::Space, Z3i::KSpace>(3,
124  embedder4(Z2i::RealPoint(0,0),false),
125  embedder4(Z2i::RealPoint(IMAGE_PATCH_WIDTH,0),false),
126  embedder4(domainImage2D.upperBound(), false),
127  embedder4(Z2i::RealPoint(0, IMAGE_PATCH_WIDTH), false));
128  viewer.setFillColor(DGtal::Color(250,20,20,255));
129  viewer << pcenter;
130 
131 
132 
133  viewer << Viewer3D<>::updateDisplay;
134 
135 
136  bool res = application.exec();
137  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
138  trace.endBlock();
139  return res ? 0 : 1;
140 
141 }
142 // //
144 
virtual void setFillColor(DGtal::Color aColor)
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
int main(int argc, char **argv)
const Point & upperBound() const
STL namespace.
double endBlock()
static TContainer import(const std::string &filename, std::vector< unsigned int > dimSpace=std::vector< unsigned int >())
Aim: Define a simple default functor that just returns its argument.
std::ostream & emphase()
Aim: Functor that embeds a 2D point into a 3D space from two axis vectors and an origin point given i...
DGtal is the top-level namespace which contains all DGtal functions and types.
Structure representing an RGB triple with alpha component.
Definition: Color.h:66
Aim: implements a const image adapter with a given domain (i.e. a subdomain) and 2 functors : g for d...
const int IMAGE_PATCH_WIDTH