DGtal  1.3.beta
tutorial-examples/2DSliceImageFromVol.cpp

Example of tutorial 5: ImageAdapter: some simple image manipulations

See also
Tutorial "Image -> ImageAdapter: some simple image manipulations"
Result of slice image number 20 on Z axis.

#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"
using namespace std;
using namespace DGtal;
using namespace Z2i;
int main(int argc, char ** argv)
{
if(argc < 3)
{
trace.error() << "You need to indicate the volumetric image name and slice number as parameters." << std::endl;
trace.error() << std::endl;
return 1;
}
std::string filename(argv[1]);
std::string outputFileName = "sliceImage.pgm";
unsigned int numSlice = atoi(argv[2]);
trace.beginBlock("Loading file");
Image3D image3d = GenericReader< Image3D >::import ( filename );
Image3D::Value, functors::Identity > SliceImageAdapter;
Z2i::Domain domain2D(proj(image3d.domain().lowerBound()),
proj(image3d.domain().upperBound()));
DGtal::functors::Projector<Z3i::Space> aSliceFunctor(numSlice);
aSliceFunctor.initAddOneDim(2);
SliceImageAdapter sliceImageZ(image3d, domain2D, aSliceFunctor, id);
trace.beginBlock("Exporting...");
sliceImageZ >> outputFileName;
return 0;
}
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:106
DGtal::HyperRectDomain< Space >
DGtal::Trace::endBlock
double endBlock()
DGtal::ImageContainerBySTLVector
Definition: ImageContainerBySTLVector.h:126
DGtal::Trace::error
std::ostream & error()
DGtal::trace
Trace trace
Definition: Common.h:154
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::GenericReader
Aim: Provide a mechanism to load with the bestloader according to an image (2D or 3D) filename (by pa...
Definition: GenericReader.h:101
DGtal::functors::Identity
Aim: Define a simple default functor that just returns its argument.
Definition: BasicFunctors.h:287
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:105
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::functors::Projector::initAddOneDim
void initAddOneDim(const Dimension &newDim)
main
int main(int argc, char **argv)
Definition: testArithmeticDSS-benchmark.cpp:147
Value
double Value
Definition: testSimpleRandomAccessRangeFromPoint.cpp:38