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
ctopo-2-3d.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/topology/KhalimskySpaceND.h"
#include "DGtal/topology/helpers/Surfaces.h"
#include "DGtal/io/viewers/PolyscopeViewer.h"
#include "DGtal/io/readers/VolReader.h"
#include "DGtal/images/ImageSelector.h"
#include "DGtal/images/imagesSetsUtils/SetFromImage.h"
#include "DGtal/io/Color.h"
#include "DGtal/io/colormaps/GradientColorMap.h"
#include "ConfigExamples.h"
Include dependency graph for ctopo-2-3d.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/05/22

An example file named ctopo-2-3d.

This file is part of the DGtal library.

Definition in file ctopo-2-3d.cpp.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 52 of file ctopo-2-3d.cpp.

53{
54 trace.beginBlock ( "Example ctopo-2-3d" );
55 // for 3D display with PolyscopeViewer
56
58 std::string inputFilename = examplesPath + "samples/cat10.vol";
60 Z3i::DigitalSet set3d (image.domain());
62
63 // Construct the Khalimsky space from the image domain
64 Z3i::KSpace ks;
65 bool space_ok = ks.init( image.domain().lowerBound(), image.domain().upperBound(), true );
66
67 if (!space_ok)
68 {
69 trace.error() << "Error in the Khamisky space construction."<<std::endl;
70 return 2;
71 }
72
73 std::vector<Z3i::SCell> vectBdrySCell;
74 std::vector<Z3i::SCell> vectBdrySCell2;
75 std::set<Z3i::SCell> vectBdrySCellALL;
76 SurfelAdjacency<3> SAdj( true );
77
78
79 //Extract an initial boundary cell
81 trace.info() << "Tracking Boundary.."<<std::endl;
82 // Extracting all boundary surfels which are connected to the initial boundary Cell.
84 ks,SAdj, set3d, aCell );
85
86 // Extract the bondary contour associated to the initial surfel in its first direction
88 ks, *(ks.sDirs( aCell )), SAdj,
89 set3d, aCell );
90
91 // Extract the bondary contour associated to the initial surfel in its second direction
93 ks, *(++(ks.sDirs( aCell ))), SAdj,
94 set3d, aCell );
95
96
97 // Displaying all the surfels in transparent mode
98 typedef PolyscopeViewer <Z3i::Space,Z3i::KSpace> MyViewer;
99 MyViewer viewer(ks);
100
101 trace.info() << "Displaying the surfels.."<<std::endl;
102 for( std::set<Z3i::SCell>::iterator it=vectBdrySCellALL.begin();
103 it!= vectBdrySCellALL.end(); it++){
104 viewer<< *it;
105 }
106 trace.info()<<"done"<<std::endl;
107 // Displaying First surfels cut with gradient colors.;
108 GradientColorMap<int> cmap_grad(0, (const int)vectBdrySCell2.size());
109 cmap_grad.addColor( Color( 50, 50, 255 ) );
110 cmap_grad.addColor( Color( 255, 0, 0 ) );
111 cmap_grad.addColor( Color( 255, 255, 10 ) );
112
113 // Need to avoid surfel superposition (the surfel size in increased)
114 viewer.drawColor(Color(180, 200, 25, 255));
115
116 int d=0;
117 for( std::vector<Z3i::SCell>::iterator it=vectBdrySCell2.begin();
118 it!= vectBdrySCell2.end(); it++){
119 Color col= cmap_grad(d);
120 viewer.drawColor(Color(col.red(),col.green() ,col.blue(), 255));
121 viewer<< *it;
122 d++;
123 }
124
125 GradientColorMap<int> cmap_grad2(0, (const int)vectBdrySCell.size());
126 cmap_grad2.addColor( Color( 50, 50, 255 ) );
127 cmap_grad2.addColor( Color( 255, 0, 0 ) );
128 cmap_grad2.addColor( Color( 255, 255, 10 ) );
129
130 d=0;
131 for( std::vector<Z3i::SCell>::iterator it=vectBdrySCell.begin();
132 it!= vectBdrySCell.end(); it++){
133 Color col= cmap_grad2(d);
134 viewer.drawColor(Color(col.red(),col.green() ,col.blue(), 255));
135 viewer<< *it;
136 d++;
137 }
138
139 // On need once again to avoid superposition.
140 viewer.drawColor(Color(18, 200, 25, 255));
141 viewer << aCell ;
142
143 viewer.show();
144 return 0;
145}
Structure representing an RGB triple with alpha component.
Definition Color.h:77
void green(const unsigned char aGreenValue)
void red(const unsigned char aRedValue)
void blue(const unsigned char aBlueValue)
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
Aim: implements association bewteen points lying in a digital domain and values.
Definition Image.h:70
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
DirIterator sDirs(const SCell &p) const
Given a signed cell [p], returns an iterator to iterate over each coordinate the cell spans.
static void trackBoundary(SCellSet &surface, const KSpace &K, const SurfelAdjacency< KSpace::dimension > &surfel_adj, const PointPredicate &pp, const SCell &start_surfel)
static SCell findABel(const KSpace &K, const PointPredicate &pp, unsigned int nbtries=1000)
static void track2DSliceBoundary(std::vector< SCell > &aSCellContour2D, const KSpace &K, const Dimension &trackDir, const SurfelAdjacency< KSpace::dimension > &surfel_adj, const PointPredicate &pp, const SCell &start_surfel)
Aim: Represent adjacencies between surfel elements, telling if it follows an interior to exterior ord...
KhalimskySpaceND< 3, Integer > KSpace
Definition StdDefs.h:146
KSpace::SCell SCell
Definition StdDefs.h:149
DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet
Definition StdDefs.h:173
Trace trace
ImageContainerBySTLVector< Domain, Value > Type
static void append(Set &aSet, const ForegroundPredicate &isForeground, typename Image::Domain::ConstIterator itBegin, typename Image::Domain::ConstIterator itEnd)
static ImageContainer importVol(const std::string &filename, const Functor &aFunctor=Functor())
Image image(domain)
PolyscopeViewer< Space, KSpace > MyViewer

References DGtal::GradientColorMap< PValue, PDefaultPreset, PDefaultFirstColor, PDefaultLastColor >::addColor(), DGtal::SetFromImage< TSet >::append(), DGtal::Color::blue(), DGtal::Display3D< Space, KSpace >::drawColor(), DGtal::Surfaces< TKSpace >::findABel(), DGtal::Color::green(), image(), DGtal::VolReader< TImageContainer, TFunctor >::importVol(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), DGtal::Color::red(), DGtal::KhalimskySpaceND< dim, TInteger >::sDirs(), DGtal::PolyscopeViewer< Space, KSpace >::show(), DGtal::trace, DGtal::Surfaces< TKSpace >::track2DSliceBoundary(), and DGtal::Surfaces< TKSpace >::trackBoundary().