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
3dKSSurfaceExtraction.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/io/readers/VolReader.h"
#include "DGtal/io/viewers/PolyscopeViewer.h"
#include "DGtal/io/Color.h"
#include "DGtal/images/ImageSelector.h"
#include "DGtal/helpers/StdDefs.h"
#include "ConfigExamples.h"
#include "DGtal/io/colormaps/GradientColorMap.h"
#include "DGtal/topology/KhalimskySpaceND.h"
#include "DGtal/topology/helpers/Surfaces.h"
Include dependency graph for 3dKSSurfaceExtraction.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
2011/06/27

An example file named 3dKSSurfaceExtraction.

This file is part of the DGtal library.

Definition in file 3dKSSurfaceExtraction.cpp.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 67 of file 3dKSSurfaceExtraction.cpp.

68{
69
70 Point p1( 0, 0, 0 );
71 Point p2( 20, 20, 20 );
72 Point c( 10, 10, 10 );
73 Domain domain( p1, p2);
74
75 // Generate the digital set from randam seeds and distance threshold.
76 DigitalSet diamond_set( domain );
77 //srand ( time(NULL) );
78 unsigned int nbSeeds = 35;
79 vector<Point> vCenters;
80 vector<uint> vRad;
81 for(unsigned int i=0;i<nbSeeds; i++){
82 vCenters.push_back(Point(rand()%p2[0], rand()%p2[1],
83 rand()%p2[2]));
84 vRad.push_back(rand()%7);
85 }
86 for ( Domain::ConstIterator it = domain.begin(); it != domain.end(); ++it ){
87 for(unsigned int i=0;i<nbSeeds; i++){
88 if ( (*it - vCenters.at(i) ).norm1() <= vRad.at(i) && domain.isInside(*it) &&
89 domain.isInside(*it+Point(1,1,1)) && domain.isInside(*it-Point(1,1,1)) ){
90 diamond_set.insertNew( *it );
91 break;
92 }
93 }
94 }
95
96
97 //A KhalimskySpace is constructed from the domain boundary points.
98 KSpace K;
99 K.init(p1, p2, true);
100
101 SurfelAdjacency<3> SAdj( true );
102 vector<vector<SCell> > vectConnectedSCell;
103
104
105 //Here since the last argument is set to true, the resulting
106 //SignedKhalimskySpaceND are signed in order to indicate the direction
107 //of exterior. You can also get the SignefKhalimskySpaceND with default
108 //sign:
109
110 Surfaces<KSpace>::extractAllConnectedSCell(vectConnectedSCell,K, SAdj, diamond_set, false);
111
112
113 PolyscopeViewer<> viewer (K);
114
115
116 // Each connected compoments are simply displayed with a specific color.
117 GradientColorMap<long> gradient(0, (const long)vectConnectedSCell.size());
118 gradient.addColor(Color::Red);
119 gradient.addColor(Color::Yellow);
120 gradient.addColor(Color::Green);
121 gradient.addColor(Color::Cyan);
122 gradient.addColor(Color::Blue);
123 gradient.addColor(Color::Magenta);
124 gradient.addColor(Color::Red);
125
126
127 for(unsigned int i=0; i< vectConnectedSCell.size();i++){
128 DGtal::Color col= gradient(i);
129 viewer << col;
130 for(unsigned int j=0; j< vectConnectedSCell.at(i).size();j++){
131 viewer << vectConnectedSCell.at(i).at(j);
132 }
133 }
134
135
136 viewer << Color(250, 200,200, 200);
137 viewer << diamond_set;
138 //viewer << ClippingPlane(0,1,0.0,-2);
139 viewer.show();
140 return 0;
141}
Structure representing an RGB triple with alpha component.
Definition Color.h:77
static const Color Red
Definition Color.h:425
static const Color Blue
Definition Color.h:428
static const Color Yellow
Definition Color.h:431
static const Color Cyan
Definition Color.h:429
static const Color Green
Definition Color.h:426
static const Color Magenta
Definition Color.h:430
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
static void extractAllConnectedSCell(std::vector< std::vector< SCell > > &aVectConnectedSCell, const KSpace &aKSpace, const SurfelAdjacency< KSpace::dimension > &aSurfelAdj, const PointPredicate &pp, bool forceOrientCellExterior=false)
Aim: Represent adjacencies between surfel elements, telling if it follows an interior to exterior ord...
KhalimskySpaceND< 3, Integer > KSpace
Definition StdDefs.h:146
Space::Point Point
Definition StdDefs.h:168
DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet
Definition StdDefs.h:173
KSpace K
Domain domain

References DGtal::GradientColorMap< PValue, PDefaultPreset, PDefaultFirstColor, PDefaultLastColor >::addColor(), DGtal::Color::Blue, DGtal::Color::Cyan, domain, DGtal::Surfaces< TKSpace >::extractAllConnectedSCell(), DGtal::Color::Green, DGtal::DigitalSetByAssociativeContainer< TDomain, TContainer >::insertNew(), K, DGtal::Color::Magenta, DGtal::Color::Red, DGtal::PolyscopeViewer< Space, KSpace >::show(), and DGtal::Color::Yellow.