DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
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
55
using namespace
std
;
56
using namespace
DGtal
;
57
58
int
main
()
59
{
60
PolyscopeViewer
viewer;
61
62
typedef
ImageContainerBySTLVector<Z3i::Domain, unsigned char >
Image3D;
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
// //
DGtal::Display3D::allowReuseList
bool allowReuseList
Definition
Display3D.h:749
DGtal::HyperRectDomain< Space >::ConstIterator
Iterator ConstIterator
Definition
HyperRectDomain.h:125
DGtal::ImageContainerBySTLVector
Definition
ImageContainerBySTLVector.h:127
DGtal::PolyscopeViewer
Definition
PolyscopeViewer.h:57
DGtal::PolyscopeViewer::show
void show() override
Starts the event loop and display of elements.
Definition
PolyscopeViewer.h:73
DGtal::Z3i::Domain
HyperRectDomain< Space > Domain
Definition
StdDefs.h:172
DGtal::Z3i::Point
Space::Point Point
Definition
StdDefs.h:168
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
std
STL namespace.
DGtal::GenericReader::import
static TContainer import(const std::string &filename, std::vector< unsigned int > dimSpace=std::vector< unsigned int >())
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
examples
io
viewers
viewer3D-9-3Dimages.cpp
Generated on
for DGtal by
1.18.0