DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
extract2DSlicesImagesFrom3D.cpp
Go to the documentation of this file.
1
16
29
30
38
39
41
#include <iostream>
42
#include <sstream>
43
#include "DGtal/kernel/BasicPointFunctors.h"
44
#include "DGtal/base/Common.h"
45
#include "DGtal/helpers/StdDefs.h"
46
#include "DGtal/io/readers/VolReader.h"
47
#include "DGtal/io/writers/PGMWriter.h"
48
#include "DGtal/images/ImageSelector.h"
49
#include "DGtal/images/ConstImageAdapter.h"
50
#include "ConfigExamples.h"
52
53
using namespace
std
;
54
using namespace
DGtal
;
55
57
58
int
main
( )
59
{
60
typedef
ImageSelector < Z3i::Domain, unsigned char>::Type
Image3D;
61
typedef
ImageSelector < Z2i::Domain, unsigned char>::Type
Image2D;
62
typedef
DGtal::ConstImageAdapter<Image3D, Image2D::Domain, DGtal::functors::Projector<Z3i::Space>
,
63
Image3D::Value,
DGtal::functors::Identity
> SliceImageAdapter;
64
65
66
DGtal::functors::Projector<Z2i::Space >
proj(2);
67
68
// Importing a 3D image
69
std::string filename = examplesPath +
"samples/lobster.vol"
;
70
Image3D
image
=
VolReader<Image3D>::importVol
( filename );
71
DGtal::Z2i::Domain
domain
(proj(
image
.
domain
().
lowerBound
()),
72
proj(
image
.
domain
().
upperBound
()));
73
DGtal::functors::Identity
idV;
74
75
trace
.
beginBlock
(
"Example extract2DImagesFrom3D"
);
76
77
// Extracting 2D slices ... and export them in the pgm format.
78
for
(
unsigned
int
i=0; i<30; i+=10){
79
std::stringstream name;
80
name <<
"lobsterSliceZ_"
<< i <<
".pgm"
;
81
DGtal::functors::Projector<Z3i::Space>
aSliceFunctor(i); aSliceFunctor.
initAddOneDim
(2);
82
SliceImageAdapter sliceImageZ(
image
,
domain
, aSliceFunctor, idV);
83
PGMWriter<SliceImageAdapter>::exportPGM
(name.str(), sliceImageZ);
84
}
85
86
// trace.endBlock();
87
return
0;
88
}
89
// //
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::lowerBound
const Point & lowerBound() const
DGtal::HyperRectDomain::upperBound
const Point & upperBound() const
DGtal::Image::domain
const Domain & domain() const
Definition
Image.h:192
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
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
DGtal::trace
Trace trace
std
STL namespace.
DGtal::ImageSelector::Type
ImageContainerBySTLVector< Domain, Value > Type
Definition
ImageSelector.h:84
DGtal::PGMWriter::exportPGM
static bool exportPGM(const std::string &filename, const Image &aImage, const Functor &aFunctor=Functor(), bool saveASCII=false, bool topbotomOrder=true)
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)
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
domain
Domain domain
Definition
testProjection.cpp:88
image
Image image(domain)
examples
images
extract2DSlicesImagesFrom3D.cpp
Generated on
for DGtal by
1.18.0