Loading [MathJax]/extensions/TeX/AMSsymbols.js
DGtal 2.0.0
viewer3D-9-3Dimages.cpp
Go to the documentation of this file.
1
16
29
30
31
37
38
39
41#include <iostream>
42#include "DGtal/base/Common.h"
43#include "DGtal/io/readers/GenericReader.h"
44#include "DGtal/images/ImageHelper.h"
45#include "DGtal/images/Image.h"
46#include "ConfigExamples.h"
47
48#include "DGtal/helpers/StdDefs.h"
49
50#include "DGtal/io/viewers/PolyscopeViewer.h"
51#include "DGtal/io/Color.h"
52
54
55using namespace std;
56using namespace DGtal;
57
58int main( int argc, char** argv )
59{
60 PolyscopeViewer viewer;
61
63
64 std::string inputFilename = examplesPath + "samples/lobster.vol";
65 Image3D imageVol = GenericReader<Image3D>::import(inputFilename);
66
67 Z3i::Point ptLow (100, 100, 20);
68 Z3i::Point ptUpp (200, 200, 40);
69 Z3i::Domain subDomain(ptLow, ptUpp);
70
71 Z3i::Point ptLow2 (220, 50, 10);
72 Z3i::Point ptUpp2 (260, 100, 20);
73 Z3i::Domain subDomain2(ptLow2, ptUpp2);
74
75 Image3D imageCrop(subDomain);
76 Image3D imageCrop2(subDomain2);
77
78 // Adding too many single point is slow and will
79 // makke the view laggy
80 // This parameter allows to reuse some list if
81 // possible (but it won't work if multiples types are
82 // inserted)
83 viewer.allowReuseList = true;
84
85 for(Z3i::Domain::ConstIterator it= imageVol.domain().begin(), itend = imageVol.domain().end(); it != itend; ++it){
86 if(imageVol(*it)>140)
87 viewer << *it;
88 Z3i::Point pt = *it;
89 if(pt[0]>=ptLow[0] && pt[1] >= ptLow[1] && pt[2] >= ptLow[2] &&
90 pt[0]<=ptUpp[0] && pt[1] <= ptUpp[1] && pt[2] <= ptUpp[2]){
91 imageCrop.setValue(*it, imageVol(*it));
92 }
93
94 if(pt[0]>=ptLow2[0] && pt[1] >= ptLow2[1] && pt[2] >= ptLow2[2] &&
95 pt[0]<=ptUpp2[0] && pt[1] <= ptUpp2[1] && pt[2] <= ptUpp2[2]){
96 imageCrop2.setValue(*it, imageVol(*it));
97 }
98 }
99 viewer << imageCrop;
100
101 viewer.show();
102 return 0;
103}
104// //
void show() override
Starts the event loop and display of elements.
HyperRectDomain< Space > Domain
Definition StdDefs.h:172
Space::Point Point
Definition StdDefs.h:168
DGtal is the top-level namespace which contains all DGtal functions and types.
STL namespace.
static TContainer import(const std::string &filename, std::vector< unsigned int > dimSpace=std::vector< unsigned int >())
int main()
Definition testBits.cpp:56