DGtal 1.3.0
No Matches
extract2DSlicesImagesFrom3D.cpp File Reference
#include <iostream>
#include <sstream>
#include "DGtal/kernel/BasicPointFunctors.h"
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/io/readers/VolReader.h"
#include "DGtal/io/writers/PGMWriter.h"
#include "DGtal/images/ImageSelector.h"
#include "DGtal/images/ConstImageAdapter.h"
#include "ConfigExamples.h"

Go to the source code of this file.


int main ()

Detailed Description

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/.

Bertrand Kerautret (kerau.nosp@m.tre@.nosp@m.loria.nosp@m..fr ) LORIA (CNRS, UMR 7503), University of Nancy, France

An example file named extract2DImagesFrom3D.

This file is part of the DGtal library.

Definition in file extract2DSlicesImagesFrom3D.cpp.

Function Documentation

◆ main()

int main ( void  )

Definition at line 58 of file extract2DSlicesImagesFrom3D.cpp.

63 Image3D::Value, DGtal::functors::Identity > SliceImageAdapter;
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()));
75 trace.beginBlock ( "Example extract2DImagesFrom3D" );
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 }
86 // trace.endBlock();
87 return 0;
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="")
Trace trace
Definition: Common.h:154
ImageContainerBySTLVector< Domain, Value > Type
Definition: ImageSelector.h:78
static bool exportPGM(const std::string &filename, const Image &aImage, const Functor &aFunctor=Functor(), bool saveASCII=false, bool topbotomOrder=true)
static ImageContainer importVol(const std::string &filename, const Functor &aFunctor=Functor())
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 ...
Domain domain

References DGtal::Trace::beginBlock(), domain, DGtal::PGMWriter< TImage, TFunctor >::exportPGM(), DGtal::VolReader< TImageContainer, TFunctor >::importVol(), DGtal::functors::Projector< S >::initAddOneDim(), and DGtal::trace.