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-9-3Dimages.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/io/readers/GenericReader.h"
#include "DGtal/images/ImageHelper.h"
#include "DGtal/images/Image.h"
#include "ConfigExamples.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/io/viewers/PolyscopeViewer.h"
#include "DGtal/io/Color.h"
Include dependency graph for viewer3D-9-3Dimages.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/05/19

An example file named viewer3D-9-3Dimages.

This file is part of the DGtal library.

Definition in file viewer3D-9-3Dimages.cpp.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 58 of file viewer3D-9-3Dimages.cpp.

59{
60 PolyscopeViewer viewer;
61
63
64 std::string inputFilename = examplesPath + "samples/lobster.vol";
65 Image3D imageVol = GenericReader<Image3D>::import(inputFilename);
66
67 Z3i::Point ptLow (100, 100, 20);
68 Z3i::Point ptUpp (200, 200, 40);
69 Z3i::Domain subDomain(ptLow, ptUpp);
70
71 Z3i::Point ptLow2 (220, 50, 10);
72 Z3i::Point ptUpp2 (260, 100, 20);
73 Z3i::Domain subDomain2(ptLow2, ptUpp2);
74
75 Image3D imageCrop(subDomain);
76 Image3D imageCrop2(subDomain2);
77
78 // Adding too many single point is slow and will
79 // makke the view laggy
80 // This parameter allows to reuse some list if
81 // possible (but it won't work if multiples types are
82 // inserted)
83 viewer.allowReuseList = true;
84
85 for(Z3i::Domain::ConstIterator it= imageVol.domain().begin(), itend = imageVol.domain().end(); it != itend; ++it){
86 if(imageVol(*it)>140)
87 viewer << *it;
88 Z3i::Point pt = *it;
89 if(pt[0]>=ptLow[0] && pt[1] >= ptLow[1] && pt[2] >= ptLow[2] &&
90 pt[0]<=ptUpp[0] && pt[1] <= ptUpp[1] && pt[2] <= ptUpp[2]){
91 imageCrop.setValue(*it, imageVol(*it));
92 }
93
94 if(pt[0]>=ptLow2[0] && pt[1] >= ptLow2[1] && pt[2] >= ptLow2[2] &&
95 pt[0]<=ptUpp2[0] && pt[1] <= ptUpp2[1] && pt[2] <= ptUpp2[2]){
96 imageCrop2.setValue(*it, imageVol(*it));
97 }
98 }
99 viewer << imageCrop;
100
101 viewer.show();
102 return 0;
103}
void show() override
Starts the event loop and display of elements.
HyperRectDomain< Space > Domain
Definition StdDefs.h:172
Space::Point Point
Definition StdDefs.h:168
static TContainer import(const std::string &filename, std::vector< unsigned int > dimSpace=std::vector< unsigned int >())

References DGtal::Display3D< Space, KSpace >::allowReuseList, DGtal::GenericReader< TContainer, Tdim, TValue >::import(), and DGtal::PolyscopeViewer< Space, KSpace >::show().