DGtal 2.0.0
Loading...
Searching...
No Matches
exampleGridCurve3d-2.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/topology/KhalimskySpaceND.h"
#include "DGtal/topology/SurfelAdjacency.h"
#include "DGtal/topology/DigitalSurface.h"
#include "DGtal/topology/SetOfSurfels.h"
#include "DGtal/topology/DigitalSurface2DSlice.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/ImageHelper.h"
#include "DGtal/kernel/sets/DigitalSetInserter.h"
#include "DGtal/io/Color.h"
#include "DGtal/geometry/curves/GridCurve.h"
#include "ConfigExamples.h"
Include dependency graph for exampleGridCurve3d-2.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
Tristan Roussillon (trist.nosp@m.an.r.nosp@m.oussi.nosp@m.llon.nosp@m.@liri.nosp@m.s.cn.nosp@m.rs.fr ) Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
Date
2012/06/03

An example file for GridCurve, defined as a sequence of 2-scells, in a 3d Khalimsky space.

This file is part of the DGtal library.

Definition in file exampleGridCurve3d-2.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

[exampleGridCurve3d-Construction]

[exampleGridCurve3d-Construction]

Definition at line 84 of file exampleGridCurve3d-2.cpp.

85{
86 trace.info() << "exampleGridCurve3d-2: the type of data to be displayed "
87 << "may be given as argument as follows: "
88 << argv[0] << " inner" << endl;
89 trace.info() << "Available types are: gridcurve (default), inner, outer, incident" << endl;
90
91 string type = (argc > 1) ? string(argv[1]) : "gridcurve";
92 trace.info() << "Chosen type: " << type << endl;
93
94 //vol reading and digital set construction
95 trace.beginBlock( "Reading vol file into an image." );
97 std::string inputFilename = examplesPath + "samples/cat10.vol";
99 DigitalSet set3d (image.domain());
101 trace.info() << set3d.size() << " voxels." << std::endl;
102 trace.endBlock();
103
104 //Khalimsky space construction
105 trace.beginBlock( "Construct the Khalimsky space from the image domain." );
106 KSpace ks;
107 trace.endBlock();
108
109 //digital surface construction
110 typedef SurfelAdjacency<KSpace::dimension> MySurfelAdjacency;
111 MySurfelAdjacency surfAdj( true ); // interior in all directions.
112
113 trace.beginBlock( "Extracting boundary by scanning the space. " );
114 typedef KSpace::Surfel Surfel;
116 typedef SetOfSurfels< KSpace, SurfelSet > MySetOfSurfels;
118 MySetOfSurfels theSetOfSurfels( ks, surfAdj );
119 Surfaces<KSpace>::sMakeBoundary( theSetOfSurfels.surfelSet(),
120 ks, set3d,
121 image.domain().lowerBound(),
122 image.domain().upperBound() );
123 MyDigitalSurface digSurf( theSetOfSurfels );
124 trace.info() << digSurf.size() << " surfels." << std::endl;
125 trace.endBlock();
126
127 //slice retrieving
128 trace.beginBlock( "Extracting slice and constructing a grid curve. " );
130 typedef DigitalSurface2DSlice< MyTracker > My2DSlice;
131
132 //Extract an initial boundary cell
133 Surfel surf = *digSurf.begin();
134 MyTracker* tracker = digSurf.container().newTracker( surf );
135
136 // Extract the bondary contour associated to the initial surfel in
137 // its first direction
138 My2DSlice slice( tracker, *(ks.sDirs( surf )) );
139 delete tracker;
140
142 GridCurve<KSpace> gc(ks);
143 gc.initFromSCellsRange( slice.begin(), slice.end() );
145
146 trace.endBlock();
147
148
149 // for 3D display with PolyscopeViewer
150 trace.beginBlock( "Display all with Viewer." );
152 // Displaying all the surfels in transparent mode
153 viewer.allowReuseList = true;
154 for( MyDigitalSurface::ConstIterator it = theSetOfSurfels.begin(),
155 it_end = theSetOfSurfels.end(); it != it_end; ++it )
156 viewer<< *it;
157
158 // Displaying slice
159 viewer << Color( 50, 50, 255 );
160
161 if (type == "gridcurve")
162 {
163 viewer << gc;
164 }
165 else if (type == "inner")
166 {
167 viewer << gc.getInnerPointsRange();
168 }
169 else if (type == "outer")
170 {
171 viewer << gc.getOuterPointsRange();
172 }
173 else if (type == "incident")
174 {
175 viewer << gc.getIncidentPointsRange();
176 }
177 else
178 {
179 trace.info() << "Display type not known." << std::endl;
180 }
181
182 trace.endBlock();
183
184 viewer.show();
185 return 0;
186}
Structure representing an RGB triple with alpha component.
Definition Color.h:77
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Aim: this output iterator class is designed to allow algorithms to insert points in the digital set....
Aim: Represents a 2-dimensional slice in a DigitalSurface. In a sense, it is a 4-connected contour,...
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
DigitalSurfaceContainer::SurfelConstIterator ConstIterator
DigitalSurfaceContainer::DigitalSurfaceTracker DigitalSurfaceTracker
Aim: describes, in a cellular space of dimension n, a closed or open sequence of signed d-cells (or d...
Definition GridCurve.h:173
Aim: implements association bewteen points lying in a digital domain and values.
Definition Image.h:70
const Domain & domain() const
Definition Image.h:192
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
std::set< SCell > SurfelSet
Preferred type for defining a set of surfels (always signed cells).
DirIterator sDirs(const SCell &p) const
Given a signed cell [p], returns an iterator to iterate over each coordinate the cell spans.
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as connected surfels....
static void sMakeBoundary(SCellSet &aBoundary, const KSpace &aKSpace, const PointPredicate &pp, const Point &aLowerBound, const Point &aUpperBound)
Aim: Represent adjacencies between surfel elements, telling if it follows an interior to exterior ord...
void beginBlock(const std::string &keyword="")
std::ostream & info()
double endBlock()
DigitalSurface< MyDigitalSurfaceContainer > MyDigitalSurface
MyDigitalSurface::SurfelSet SurfelSet
void setFromImage(const I &aImg, const O &ito, const typename I::Value &aThreshold=0)
Trace trace
ImageContainerBySTLVector< Domain, Value > Type
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
static ImageContainer importVol(const std::string &filename, const Functor &aFunctor=Functor())
Image image(domain)

References DGtal::Display3D< Space, KSpace >::allowReuseList, DGtal::DigitalSurface< TDigitalSurfaceContainer >::begin(), DGtal::Trace::beginBlock(), DGtal::DigitalSurface< TDigitalSurfaceContainer >::container(), DGtal::Image< TImageContainer >::domain(), DGtal::Trace::endBlock(), DGtal::GridCurve< TKSpace >::getIncidentPointsRange(), DGtal::GridCurve< TKSpace >::getInnerPointsRange(), DGtal::GridCurve< TKSpace >::getOuterPointsRange(), image(), DGtal::VolReader< TImageContainer, TFunctor >::importVol(), DGtal::Trace::info(), DGtal::GridCurve< TKSpace >::initFromSCellsRange(), DGtal::KhalimskySpaceND< dim, TInteger >::sDirs(), DGtal::setFromImage(), DGtal::PolyscopeViewer< Space, KSpace >::show(), DGtal::DigitalSetByAssociativeContainer< TDomain, TContainer >::size(), DGtal::DigitalSurface< TDigitalSurfaceContainer >::size(), DGtal::Surfaces< TKSpace >::sMakeBoundary(), and DGtal::trace.