File failed to load: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.3/config/TeX-MML-AM_CHTML/MathJax.js
DGtal 2.0.0
viewer3D-8-2DSliceImages.cpp File Reference
#include <iostream>
#include "DGtal/io/readers/VolReader.h"
#include "DGtal/base/Common.h"
#include "DGtal/images/ImageHelper.h"
#include "DGtal/images/ImageContainerBySTLVector.h"
#include "DGtal/kernel/BasicPointFunctors.h"
#include "ConfigExamples.h"
#include "DGtal/io/viewers/PolyscopeViewer.h"
#include "DGtal/io/Color.h"
Include dependency graph for viewer3D-8-2DSliceImages.cpp:

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

An example file named viewer3D-8-2DSliceImages .

This file is part of the DGtal library.

Definition in file viewer3D-8-2DSliceImages.cpp.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

[ExampleViewer3D2DImagesExtractImages]

[ExampleViewer3D2DImagesExtractImages]

[ExampleViewer3D2DImagesDisplayImages]

[ExampleViewer3D2DImagesDisplayImages]

[ExampleViewer3D2DModifImages]

Definition at line 51 of file viewer3D-8-2DSliceImages.cpp.

52{
53 PolyscopeViewer viewer;
54
56 std::string inputFilename = examplesPath + "samples/lobster.vol";
57 Image3D imageVol = VolReader<Image3D>::importVol(inputFilename);
58
60 // Extracting the 2D images from the 3D one and from a given dimension.
61 // First image the teenth Z slice (dim=2)
63 Image3D::Value, DGtal::functors::Identity > MySliceImageAdapter;
64
65 // Define the functor to recover a 2D domain from the 3D one in the Z direction (2):
66 DGtal::functors::Projector<DGtal::Z2i::Space> transTo2DdomainFunctorZ; transTo2DdomainFunctorZ.initRemoveOneDim(2);
67 DGtal::Z2i::Domain domain2DZ(transTo2DdomainFunctorZ(imageVol.domain().lowerBound()),
68 transTo2DdomainFunctorZ(imageVol.domain().upperBound()));
69
70 // Define the functor to associate 2D coordinates to the 3D one by giving the direction Z (2) and the slide numnber (10):
71 DGtal::functors::Projector<DGtal::Z3i::Space> aSliceFunctorZ(10); aSliceFunctorZ.initAddOneDim(2);
72
73 // We can now obtain the slice image (a ConstImageAdapter):
74 const auto identityFunctor = DGtal::functors::Identity();
75 MySliceImageAdapter aSliceImageZ(imageVol, domain2DZ, aSliceFunctorZ, identityFunctor );
76
77 // Second image the fiftieth Y slice (dim=1)
78 // Define the functor to recover a 2D domain from the 3D one in the Y direction (1):
79 DGtal::functors::Projector<DGtal::Z2i::Space> transTo2DdomainFunctorY; transTo2DdomainFunctorY.initRemoveOneDim(1);
80 DGtal::Z2i::Domain domain2DY(transTo2DdomainFunctorY(imageVol.domain().lowerBound()),
81 transTo2DdomainFunctorY(imageVol.domain().upperBound()));
82
83 // Define the functor to associate 2D coordinates to the 3D one by giving the direction Y (1) and the slide numnber (50):
84 DGtal::functors::Projector<DGtal::Z3i::Space> aSliceFunctorY(50); aSliceFunctorY.initAddOneDim(1);
85
86 // We can now obtain the slice image (a ConstImageAdapter):
87 MySliceImageAdapter aSliceImageY(imageVol, domain2DY, aSliceFunctorY, identityFunctor );
89
91 viewer.draw(aSliceImageZ);
92 std::string imageY = viewer.draw(aSliceImageY);
94 //
95
97 // Update image position by accessing the transform
98 viewer.data[imageY].transform.rotate(Eigen::AngleAxisd(M_PI / 2, Eigen::Vector3d::UnitX()));
99 viewer.data[imageY].transform.translate(Eigen::Vector3d(0, 50, -50));
100 // //! [ExampleViewer3D2DModifImages]
101
102 viewer.show();
103 return 0;
104}
Aim: implements a const image adapter with a given domain (i.e. a subdomain) and 2 functors : g for d...
std::string draw(const Point &p, const std::string &uname="Point_{i}")
std::map< std::string, DisplayData< RealPoint > > data
Definition Display3D.h:734
void show() override
Starts the event loop and display of elements.
HyperRectDomain< Space > Domain
Definition StdDefs.h:99
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 ...
void initRemoveOneDim(const Dimension &dimRemoved)

References DGtal::Display3D< Space, KSpace >::data, DGtal::Display3D< Space, KSpace >::draw(), DGtal::VolReader< TImageContainer, TFunctor >::importVol(), DGtal::functors::Projector< S >::initAddOneDim(), DGtal::functors::Projector< S >::initRemoveOneDim(), and DGtal::PolyscopeViewer< Space, KSpace >::show().