DGtal 1.3.0
Loading...
Searching...
No Matches
Functions
extract2DImagesFrom3DandVisu.cpp File Reference
#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"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

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

Author
Bertrand Kerautret (kerau.nosp@m.tre@.nosp@m.loria.nosp@m..fr ) LORIA (CNRS, UMR 7503), University of Nancy, France
Date
2013/04/24

An example file named extract2DImagesFrom3D.

This file is part of the DGtal library.

Definition in file extract2DImagesFrom3DandVisu.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 61 of file extract2DImagesFrom3DandVisu.cpp.

62{
63
64
65 QApplication application(argc,argv);
66 Viewer3D<> viewer;
67 viewer.setWindowTitle("simpleViewer");
68 viewer.show();
69
70
74 Image3D::Value, DGtal::functors::Identity > SliceImageAdapter;
75
77 Image3D::Value, DGtal::functors::Identity > ImageAdapterExtractor;
78
80 // Importing a 3D image
81 std::string filename = examplesPath + "samples/lobster.vol";
82 Image3D image = VolReader<Image3D>::importVol( filename );
83
84 DGtal::Z2i::Domain domain(invFunctor(image.domain().lowerBound()),
85 invFunctor(image.domain().upperBound()));
87
88 trace.beginBlock ( "Example extract2DImagesFrom3D" );
89
90 // Extracting 2D slices ... and visualisation on 3DViewer
91 unsigned int pos=0;
92 for (unsigned int i=0; i<30; i+=5){
93 DGtal::functors::Projector<DGtal::Z3i::Space> aSliceFunctor(i); aSliceFunctor.initAddOneDim(2);
94 SliceImageAdapter sliceImageZ(image, domain, aSliceFunctor, idV);
95 viewer << sliceImageZ;
96 viewer << DGtal::UpdateImagePosition<Z3i::Space, Z3i::KSpace>(pos, Viewer3D<>::zDirection, i*20, i*20, i*20 );
97 pos++;
98 }
99
100 // Visu extraction from points
101 const int IMAGE_PATCH_WIDTH = 40;
102
103
104 DGtal::Z3i::Point ptCenter(155, 155, 20);
105 DGtal::Z2i::Domain domainImage2D (DGtal::Z2i::Point(0,0),
107
108
109 DGtal::functors::Point2DEmbedderIn3D<DGtal::Z3i::Domain > embedder(image.domain(), ptCenter,
110 DGtal::Z3i::RealPoint(1,-1,1),
112
113 ImageAdapterExtractor extractedImage(image, domainImage2D, embedder, idV);
114 viewer << extractedImage;
115 viewer << DGtal::UpdateImage3DEmbedding<Z3i::Space, Z3i::KSpace>(pos,
116 embedder(Z2i::Point(0,0)),
117 embedder(Z2i::Point(IMAGE_PATCH_WIDTH,0)),
118 embedder(domainImage2D.upperBound()),
119 embedder(Z2i::RealPoint(0, IMAGE_PATCH_WIDTH)));
120
121
122
123 viewer << DGtal::Viewer3D<>::updateDisplay;
124
125
126 application.exec();
127 return 0;
128}
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="")
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
Aim: Functor that embeds a 2D point into a 3D space from two axis vectors and an origin point given i...
const int IMAGE_PATCH_WIDTH
Trace trace
Definition: Common.h:154
ImageContainerBySTLVector< Domain, Value > Type
Definition: ImageSelector.h:78
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, IMAGE_PATCH_WIDTH, DGtal::VolReader< TImageContainer, TFunctor >::importVol(), DGtal::functors::Projector< S >::initAddOneDim(), DGtal::Viewer3D< TSpace, TKSpace >::show(), DGtal::trace, and DGtal::HyperRectDomain< TSpace >::upperBound().