DGtal 2.1.0
Loading...
Searching...
No Matches
2DSliceImageFromVol.cpp File Reference

Example associated to the tutorial 5 on Image adapter. More...

#include <iostream>
#include <DGtal/base/Common.h>
#include "DGtal/io/readers/GenericReader.h"
#include "DGtal/io/writers/GenericWriter.h"
#include <DGtal/helpers/StdDefs.h>
#include <DGtal/images/ImageContainerBySTLVector.h>
#include <DGtal/images/ConstImageAdapter.h>
#include "DGtal/kernel/BasicPointFunctors.h"
Include dependency graph for 2DSliceImageFromVol.cpp:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example associated to the tutorial 5 on Image adapter.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
Bertrand Kerautret (bertr.nosp@m.and..nosp@m.kerau.nosp@m.tret.nosp@m.@lori.nosp@m.a.fr ) LORIA (CNRS, UMR 7503), University of Lorraine, France
Date
2016/05/09

This file is part of the DGtal library.

Definition in file 2DSliceImageFromVol.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 49 of file 2DSliceImageFromVol.cpp.

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
82
83 trace.beginBlock("Exporting...");
84 sliceImageZ >> outputFileName;
86 return 0;
87}
Aim: implements a const image adapter with a given domain (i.e. a subdomain) and 2 functors : g for d...
void beginBlock(const std::string &keyword="")
std::ostream & error()
double endBlock()
Trace trace
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 ...

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::Trace::error(), DGtal::GenericReader< TContainer, Tdim, TValue >::import(), DGtal::functors::Projector< S >::initAddOneDim(), and DGtal::trace.