Loading [MathJax]/extensions/TeX/AMSsymbols.js
DGtal 2.0.0
2DSliceImageFromVol.cpp
Go to the documentation of this file.
1
16
30
31#include <iostream>
32#include <DGtal/base/Common.h>
33#include "DGtal/io/readers/GenericReader.h"
34#include "DGtal/io/writers/GenericWriter.h"
35
36#include <DGtal/helpers/StdDefs.h>
37#include <DGtal/images/ImageContainerBySTLVector.h>
38#include <DGtal/images/ConstImageAdapter.h>
39
40
41#include "DGtal/kernel/BasicPointFunctors.h"
42
43using namespace std;
44using namespace DGtal;
45using namespace Z2i;
46
47
48
49int main(int argc, char ** argv)
50{
51
54
55 if(argc < 3)
56 {
57 trace.error() << "You need to indicate the volumetric image name and slice number as parameters." << std::endl;
58 trace.error() << std::endl;
59 return 1;
60 }
61 std::string filename(argv[1]);
62 std::string outputFileName = "sliceImage.pgm";
63
64 unsigned int numSlice = atoi(argv[2]);
65
66 trace.beginBlock("Loading file");
67 Image3D image3d = GenericReader< Image3D >::import ( filename );
68
69
72 Image3D::Value, functors::Identity > SliceImageAdapter;
74 Z2i::Domain domain2D(proj(image3d.domain().lowerBound()),
75 proj(image3d.domain().upperBound()));
76
77 DGtal::functors::Projector<Z3i::Space> aSliceFunctor(numSlice);
78 aSliceFunctor.initAddOneDim(2);
79 SliceImageAdapter sliceImageZ(image3d, domain2D, aSliceFunctor, id);
80
81 trace.endBlock();
82
83 trace.beginBlock("Exporting...");
84 sliceImageZ >> outputFileName;
85 trace.endBlock();
86 return 0;
87}
Aim: implements a const image adapter with a given domain (i.e. a subdomain) and 2 functors : g for d...
Z2i this namespace gathers the standard of types for 2D imagery.
HyperRectDomain< Space > Domain
Definition StdDefs.h:99
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
STL namespace.
static TContainer import(const std::string &filename, std::vector< unsigned int > dimSpace=std::vector< unsigned int >())
Aim: Define a simple default functor that just returns its argument.
Aim: Functor that maps a point P of dimension i to a point Q of dimension j. The member myDims is an ...
void initAddOneDim(const Dimension &newDim)
int main()
Definition testBits.cpp:56