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"
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;
return 1;
}
std::string filename(argv[1]);
std::string outputFileName = "sliceImage.pgm";
unsigned int numSlice = atoi(argv[2]);
Z2i::Domain domain2D(proj(image3d.domain().lowerBound()),
proj(image3d.domain().upperBound()));
SliceImageAdapter sliceImageZ(image3d, domain2D, aSliceFunctor, id);
sliceImageZ >> outputFileName;
return 0;
}