DGtal
2.1.0
Loading...
Searching...
No Matches
viewer3D-8bis-2Dimages.cpp
Go to the documentation of this file.
1
38
#include "DGtal/base/Common.h"
39
#include "DGtal/io/readers/VolReader.h"
40
#include "DGtal/images/ImageHelper.h"
41
#include "ConfigExamples.h"
42
#include "DGtal/io/viewers/PolyscopeViewer.h"
43
45
#include "DGtal/kernel/BasicPointFunctors.h"
47
49
50
using namespace
std
;
51
using namespace
DGtal
;
52
54
55
int
main
()
56
{
57
58
typedef
DGtal::ImageContainerBySTLVector<DGtal::Z3i::Domain, unsigned char >
Image3D;
60
typedef
DGtal::ConstImageAdapter<Image3D, Z2i::Domain, DGtal::functors::Point2DEmbedderIn3D<DGtal::Z3i::Domain>
,
61
Image3D::Value,
DGtal::functors::Identity
> ImageAdapterExtractor;
62
64
polyscope::options::programName =
"examples/io/viewers: viewer3D-8bis-2Dimages"
;
65
PolyscopeViewer
viewer;
66
67
68
69
std::string inputFilename = examplesPath +
"samples/lobster.vol"
;
70
Image3D imageVol =
VolReader<Image3D>::importVol
(inputFilename);
71
DGtal::functors::Identity
idV;
72
73
74
76
DGtal::Z3i::Point
ptCenter(50, 62, 28);
77
const
int
IMAGE_PATCH_WIDTH
= 30;
78
// Setting the image domain of the resulting image to be displayed in 3D:
79
DGtal::Z2i::Domain
domainImage2D (
DGtal::Z2i::Point
(0,0),
80
DGtal::Z2i::Point
(
IMAGE_PATCH_WIDTH
,
IMAGE_PATCH_WIDTH
));
82
83
84
85
unsigned
int
pos=0;
86
for
(
double
alpha = 0; alpha< 1.54; alpha+= 0.01){
88
// Extracting images from 3D embeder
89
DGtal::functors::Point2DEmbedderIn3D<DGtal::Z3i::Domain >
embedder(imageVol.domain(),
90
ptCenter+
DGtal::Z3i::Point
(
static_cast<
int
>
(200.0*cos(alpha)),
91
static_cast<
int
>
(100.0*sin(alpha))),
92
DGtal::Z3i::RealPoint
(cos(alpha),sin(alpha),cos(2.0*alpha)),
93
IMAGE_PATCH_WIDTH
);
94
ImageAdapterExtractor extractedImage(imageVol, domainImage2D, embedder, idV);
96
98
//Display image and update its position
99
viewer << extractedImage;
101
pos++;
102
}
103
104
105
106
viewer.
show
();
107
return
EXIT_SUCCESS;
108
109
}
110
// //
112
113
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::HyperRectDomain< Space >
DGtal::ImageContainerBySTLVector
Definition
ImageContainerBySTLVector.h:127
DGtal::PointVector< dim, Integer >
DGtal::PolyscopeViewer
Definition
PolyscopeViewer.h:52
DGtal::PolyscopeViewer::show
void show() override
Starts the event loop and display of elements.
Definition
PolyscopeViewer.h:68
DGtal::functors::Point2DEmbedderIn3D
Aim: Functor that embeds a 2D point into a 3D space from two axis vectors and an origin point given i...
Definition
BasicPointFunctors.h:380
IMAGE_PATCH_WIDTH
const int IMAGE_PATCH_WIDTH
Definition
extract2DImagesFrom3D.cpp:59
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
main
int main()
Definition
viewer3D-8bis-2Dimages.cpp:55
examples
io
viewers
viewer3D-8bis-2Dimages.cpp
Generated on Tue Aug 26 2025 14:27:42 for DGtal by
1.9.8