DGtal  1.3.beta
images/extract2DImagesFrom3DandVisu.cpp

Example of 2D images extraction from 3D images and 3D visualisation.

Example of 3D visualisation of 2D slices images of the sample/lobster.vol file.
#include <iostream>
#include <sstream>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/images/ImageHelper.h"
#include "DGtal/io/readers/VolReader.h"
#include "DGtal/images/ImageSelector.h"
#include "DGtal/images/ConstImageAdapter.h"
#include "ConfigExamples.h"
#include "DGtal/io/viewers/Viewer3D.h"
#include "DGtal/kernel/BasicPointFunctors.h"
using namespace std;
using namespace DGtal;
int main( int argc, char** argv )
{
QApplication application(argc,argv);
Viewer3D<> viewer;
viewer.setWindowTitle("simpleViewer");
viewer.show();
Image3D::Value, DGtal::functors::Identity > ImageAdapterExtractor;
// Importing a 3D image
std::string filename = examplesPath + "samples/lobster.vol";
Image3D image = VolReader<Image3D>::importVol( filename );
DGtal::Z2i::Domain domain(invFunctor(image.domain().lowerBound()),
invFunctor(image.domain().upperBound()));
trace.beginBlock ( "Example extract2DImagesFrom3D" );
// Extracting 2D slices ... and visualisation on 3DViewer
unsigned int pos=0;
for (unsigned int i=0; i<30; i+=5){
SliceImageAdapter sliceImageZ(image, domain, aSliceFunctor, idV);
viewer << sliceImageZ;
viewer << DGtal::UpdateImagePosition<Z3i::Space, Z3i::KSpace>(pos, Viewer3D<>::zDirection, i*20, i*20, i*20 );
pos++;
}
// Visu extraction from points
const int IMAGE_PATCH_WIDTH = 40;
DGtal::Z3i::Point ptCenter(155, 155, 20);
ImageAdapterExtractor extractedImage(image, domainImage2D, embedder, idV);
viewer << extractedImage;
viewer << DGtal::UpdateImage3DEmbedding<Z3i::Space, Z3i::KSpace>(pos,
embedder(Z2i::Point(0,0)),
embedder(domainImage2D.upperBound()),
viewer << DGtal::Viewer3D<>::updateDisplay;
application.exec();
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::ImageContainerBySTLVector
Definition: ImageContainerBySTLVector.h:126
DGtal::HyperRectDomain::upperBound
const Point & upperBound() const
DGtal::trace
Trace trace
Definition: Common.h:154
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
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::Viewer3D
Definition: Viewer3D.h:135
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
domain
Domain domain
Definition: testProjection.cpp:88
DGtal::PointVector< dim, Integer >
DGtal::VolReader
Aim: implements methods to read a "Vol" file format.
Definition: VolReader.h:89
DGtal::Viewer3D::show
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
IMAGE_PATCH_WIDTH
const int IMAGE_PATCH_WIDTH
Definition: extract2DImagesFrom3D.cpp:59
Value
double Value
Definition: testSimpleRandomAccessRangeFromPoint.cpp:38
DGtal::functors::Point2DEmbedderIn3D
Aim: Functor that embeds a 2D point into a 3D space from two axis vectors and an origin point given i...
Definition: BasicPointFunctors.h:372