DGtal  0.9.3
Functions
viewer3D-8-2DSliceImages.cpp File Reference
#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/io/DrawWithDisplay3DModifier.h"
#include "DGtal/io/viewers/DrawWithViewer3DModifier.h"
#include "DGtal/io/colormaps/HueShadeColorMap.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 
)

[ExampleViewer3D2DImagesExtractImagesColorFct]

[ExampleViewer3D2DImagesExtractImages]

[ExampleViewer3D2DImagesExtractImages]

[ExampleViewer3D2DChangeMode]

[ExampleViewer3D2DChangeMode]

[ExampleViewer3D2DImagesDisplayImages]

[ExampleViewer3D2DImagesDisplayImages]

[ExampleViewer3D2DImagesDisplayImagesColor]

[ExampleViewer3D2DImagesDisplayImagesColor]

[ExampleViewer3D2DModifImages]

[ExampleViewer3D2DModifImages]

[ExampleViewer3D2DModifImagesColor]

[ExampleViewer3D2DModifImagesColor]

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

References DGtal::Trace::endBlock(), DGtal::functors::Projector< S >::initAddOneDim(), DGtal::functors::Projector< S >::initRemoveOneDim(), DGtal::Viewer3D< Space, KSpace >::show(), DGtal::trace, DGtal::Display3D< Space, KSpace >::updateDisplay, DGtal::Viewer3D< Space, KSpace >::yDirection, and DGtal::Viewer3D< Space, KSpace >::zDirection.

70 {
71 
73  QApplication application(argc,argv);
74  typedef Viewer3D<> MyViewer;
75  MyViewer viewer;
76  viewer.show();
77  std::string inputFilename = examplesPath + "samples/lobster.vol";
78  Image3D imageVol = VolReader<Image3D>::importVol(inputFilename);
79 
80 
82  // Extracting the 2D images from the 3D one and from a given dimension.
83  // First image the teenth Z slice (dim=2)
85  Image3D::Value, DGtal::functors::Identity > MySliceImageAdapter;
86 
87  // Define the functor to recover a 2D domain from the 3D one in the Z direction (2):
88  DGtal::functors::Projector<DGtal::Z2i::Space> transTo2DdomainFunctorZ; transTo2DdomainFunctorZ.initRemoveOneDim(2);
89  DGtal::Z2i::Domain domain2DZ(transTo2DdomainFunctorZ(imageVol.domain().lowerBound()),
90  transTo2DdomainFunctorZ(imageVol.domain().upperBound()));
91 
92  // Define the functor to associate 2D coordinates to the 3D one by giving the direction Z (2) and the slide numnber (10):
93  DGtal::functors::Projector<DGtal::Z3i::Space> aSliceFunctorZ(10); aSliceFunctorZ.initAddOneDim(2);
94 
95  // We can now obtain the slice image (a ConstImageAdapter):
96  const auto identityFunctor = DGtal::functors::Identity();
97  MySliceImageAdapter aSliceImageZ(imageVol, domain2DZ, aSliceFunctorZ, identityFunctor );
98 
99  // Second image the fiftieth Y slice (dim=1)
100  // Define the functor to recover a 2D domain from the 3D one in the Y direction (1):
101  DGtal::functors::Projector<DGtal::Z2i::Space> transTo2DdomainFunctorY; transTo2DdomainFunctorY.initRemoveOneDim(1);
102  DGtal::Z2i::Domain domain2DY(transTo2DdomainFunctorY(imageVol.domain().lowerBound()),
103  transTo2DdomainFunctorY(imageVol.domain().upperBound()));
104 
105  // Define the functor to associate 2D coordinates to the 3D one by giving the direction Y (1) and the slide numnber (50):
106  DGtal::functors::Projector<DGtal::Z3i::Space> aSliceFunctorY(50); aSliceFunctorY.initAddOneDim(1);
107 
108  // We can now obtain the slice image (a ConstImageAdapter):
109  MySliceImageAdapter aSliceImageY(imageVol, domain2DY, aSliceFunctorY, identityFunctor );
111 
113  viewer << SetMode3D(aSliceImageZ.className(), "BoundingBox");
114  viewer << MyViewer::updateDisplay;
116 
118  viewer << aSliceImageZ;
119  viewer << aSliceImageY;
121 
122  viewer << SetMode3D(aSliceImageZ.className(), "");
124  viewer << AddTextureImage2DWithFunctor<MySliceImageAdapter, hueFct, Z3i::Space, Z3i::KSpace> (aSliceImageZ, hueFct(), Viewer3D<Z3i::Space, Z3i::KSpace>::RGBMode);
125  viewer << AddTextureImage2DWithFunctor<MySliceImageAdapter, hueFct, Z3i::Space, Z3i::KSpace> (aSliceImageY, hueFct(), Viewer3D<Z3i::Space, Z3i::KSpace>::RGBMode);
127 
128 
130  viewer << DGtal::UpdateImagePosition<Z3i::Space, Z3i::KSpace>(1, MyViewer::yDirection, 0.0, 50.0, 0.0);
131  viewer << DGtal::UpdateImageData<MySliceImageAdapter>(0, aSliceImageZ, 0, 0, 10);
132  viewer << MyViewer::updateDisplay;
134 
135 
137  viewer << DGtal::UpdateImagePosition<Z3i::Space, Z3i::KSpace>(3, MyViewer::yDirection, 500.0, 50.0, 0.0);
138  viewer << DGtal::UpdateImageData<MySliceImageAdapter, hueFct>(2, aSliceImageZ, 500, 0, 10, 0.0, MyViewer::zDirection, hueFct());
139  viewer << MyViewer::updateDisplay;
141 
142 return application.exec();
143 
144  trace.endBlock();
145  return 0;
146 }
Trace trace
Definition: Common.h:137
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
double endBlock()
void initRemoveOneDim(const Dimension &dimRemoved)
Aim: Functor that maps a point P of dimension i to a point Q of dimension j. The member myDims is an ...
Aim: Define a simple default functor that just returns its argument.
Aim: implements methods to read a "Vol" file format.
Definition: VolReader.h:89
Aim: implements a const image adapter with a given domain (i.e. a subdomain) and 2 functors : g for d...
Modifier class in a Display3D stream. Useful to choose your own mode for a given class. Realizes the concept CDrawableWithDisplay3D.