DGtal 1.3.0
Loading...
Searching...
No Matches
test3DImageViewEmbedder.cpp
Go to the documentation of this file.
1
31#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
45using namespace std;
46using namespace DGtal;
47using namespace Z3i;
48
49
50
51
53// Functions for testing class Viewer3D.
55
56
57
59// Standard services - public :
60
61int 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),
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
Structure representing an RGB triple with alpha component.
Definition: Color.h:68
Aim: implements a const image adapter with a given domain (i.e. a subdomain) and 2 functors : g for d...
virtual void setFillColor(DGtal::Color aColor)
const Point & upperBound() const
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
double endBlock()
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
Aim: Functor that embeds a 2D point into a 3D space from two axis vectors and an origin point given i...
const int IMAGE_PATCH_WIDTH
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition: Common.h:154
STL namespace.
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.
int main()
Definition: testBits.cpp:56