DGtal  0.9.3beta
io/viewers/viewer3D-8bis-2Dimages.cpp

Example of 2D image display in 3D by 3D embedding.

viewer3D-8bis.png
Illustration of multiple 2D image extraction and visualisation from 3D embedding
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/io/readers/VolReader.h"
#include "DGtal/images/ImageHelper.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 )
{
Image3D::Value, DGtal::functors::Identity > ImageAdapterExtractor;
QApplication application(argc,argv);
MyViewer viewer;
viewer.show();
std::string inputFilename = examplesPath + "samples/lobster.vol";
Image3D imageVol = VolReader<Image3D>::importVol(inputFilename);
DGtal::Z3i::Point ptCenter(50, 62, 28);
const int IMAGE_PATCH_WIDTH = 20;
// Setting the image domain of the resulting image to be displayed in 3D:
DGtal::Z2i::Point(IMAGE_PATCH_WIDTH, IMAGE_PATCH_WIDTH));
unsigned int pos=0;
for (double alpha = 0; alpha< 1.54; alpha+= 0.01){
// Extracting images from 3D embeder
ptCenter+DGtal::Z3i::RealPoint(200.0*cos(alpha),100.0*sin(alpha)),
DGtal::Z3i::RealPoint(cos(alpha),sin(alpha),cos(2.0*alpha)),
IMAGE_PATCH_WIDTH);
ImageAdapterExtractor extractedImage(imageVol, domainImage2D, embedder, idV);
//Display image and update its position with embeder
viewer << extractedImage;
viewer << DGtal::UpdateImage3DEmbedding<Z3i::Space, Z3i::KSpace>(pos,
embedder(Z2i::RealPoint(0,0)),
embedder(Z2i::RealPoint(IMAGE_PATCH_WIDTH,0)),
embedder(domainImage2D.upperBound()),
embedder(Z2i::RealPoint(0, IMAGE_PATCH_WIDTH)));
pos++;
}
return application.exec();
return 0;
}
// //