DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
viewer3D-8-2DSliceImages.cpp
Go to the documentation of this file.
1
16
29
35
37
#include <iostream>
38
#include "DGtal/io/readers/VolReader.h"
39
#include "DGtal/base/Common.h"
40
#include "DGtal/images/ImageHelper.h"
41
#include "DGtal/images/ImageContainerBySTLVector.h"
42
#include "DGtal/kernel/BasicPointFunctors.h"
43
#include "ConfigExamples.h"
44
45
#include "DGtal/io/viewers/PolyscopeViewer.h"
46
#include "DGtal/io/Color.h"
47
48
using namespace
std
;
49
using namespace
DGtal
;
50
51
int
main
()
52
{
53
PolyscopeViewer
viewer;
54
55
typedef
DGtal::ImageContainerBySTLVector<DGtal::Z3i::Domain, unsigned char >
Image3D;
56
std::string inputFilename = examplesPath +
"samples/lobster.vol"
;
57
Image3D imageVol =
VolReader<Image3D>::importVol
(inputFilename);
58
60
// Extracting the 2D images from the 3D one and from a given dimension.
61
// First image the teenth Z slice (dim=2)
62
typedef
DGtal::ConstImageAdapter<Image3D, DGtal::Z2i::Domain, DGtal::functors::Projector< DGtal::Z3i::Space>
,
63
Image3D::Value,
DGtal::functors::Identity
> MySliceImageAdapter;
64
65
// Define the functor to recover a 2D domain from the 3D one in the Z direction (2):
66
DGtal::functors::Projector<DGtal::Z2i::Space>
transTo2DdomainFunctorZ; transTo2DdomainFunctorZ.
initRemoveOneDim
(2);
67
DGtal::Z2i::Domain
domain2DZ(transTo2DdomainFunctorZ(imageVol.domain().lowerBound()),
68
transTo2DdomainFunctorZ(imageVol.domain().upperBound()));
69
70
// Define the functor to associate 2D coordinates to the 3D one by giving the direction Z (2) and the slide number (10):
71
DGtal::functors::Projector<DGtal::Z3i::Space>
aSliceFunctorZ(10); aSliceFunctorZ.
initAddOneDim
(2);
72
73
// We can now obtain the slice image (a ConstImageAdapter):
74
const
auto
identityFunctor =
DGtal::functors::Identity
();
75
MySliceImageAdapter aSliceImageZ(imageVol, domain2DZ, aSliceFunctorZ, identityFunctor );
76
77
// Second image the fiftieth Y slice (dim=1)
78
// Define the functor to recover a 2D domain from the 3D one in the Y direction (1):
79
DGtal::functors::Projector<DGtal::Z2i::Space>
transTo2DdomainFunctorY; transTo2DdomainFunctorY.
initRemoveOneDim
(1);
80
DGtal::Z2i::Domain
domain2DY(transTo2DdomainFunctorY(imageVol.domain().lowerBound()),
81
transTo2DdomainFunctorY(imageVol.domain().upperBound()));
82
83
// Define the functor to associate 2D coordinates to the 3D one by giving the direction Y (1) and the slide number (50):
84
DGtal::functors::Projector<DGtal::Z3i::Space>
aSliceFunctorY(50); aSliceFunctorY.
initAddOneDim
(1);
85
86
// We can now obtain the slice image (a ConstImageAdapter):
87
MySliceImageAdapter aSliceImageY(imageVol, domain2DY, aSliceFunctorY, identityFunctor );
89
91
viewer.
draw
(aSliceImageZ);
92
std::string imageY = viewer.
draw
(aSliceImageY);
94
//
95
96
97
viewer.
show
();
98
return
0;
99
}
100
// //
DGtal::ConstImageAdapter
Aim: implements a const image adapter with a given domain (i.e. a subdomain) and 2 functors : g for d...
Definition
ConstImageAdapter.h:106
DGtal::Display3D::draw
std::string draw(const Point &p, const std::string &uname="Point_{i}")
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::Z2i::Domain
HyperRectDomain< Space > Domain
Definition
StdDefs.h:99
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
std
STL namespace.
DGtal::VolReader::importVol
static ImageContainer importVol(const std::string &filename, const Functor &aFunctor=Functor())
DGtal::functors::Identity
Aim: Define a simple default functor that just returns its argument.
Definition
BasicFunctors.h:288
DGtal::functors::Projector
Aim: Functor that maps a point P of dimension i to a point Q of dimension j. The member myDims is an ...
Definition
BasicPointFunctors.h:107
DGtal::functors::Projector::initAddOneDim
void initAddOneDim(const Dimension &newDim)
DGtal::functors::Projector::initRemoveOneDim
void initRemoveOneDim(const Dimension &dimRemoved)
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
examples
io
viewers
viewer3D-8-2DSliceImages.cpp
Generated on
for DGtal by
1.18.0