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
- Jacques-Olivier Lachaud (
jacqu.nosp@m.es-o.nosp@m.livie.nosp@m.r.la.nosp@m.chaud.nosp@m.@uni.nosp@m.v-sav.nosp@m.oie..nosp@m.fr
) Laboratory of Mathematics (CNRS, UMR 5127), University of Savoie, France
- Date
- 2015/08/28
An example file named area-estimation-with-digital-surface.cpp.
This file is part of the DGtal library.
Definition in file area-estimation-with-digital-surface.cpp.
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 83 of file area-estimation-with-digital-surface.cpp.
85 const double R = argc >= 2 ? atof( argv[ 1 ] ) : 13.0;
86 const unsigned int KN = argc >= 3 ? atoi( argv[ 2 ] ) : 6;
87 const int M = (int) ceil( R + 2.0 );
90 <<
", " << KN <<
"-ring neighborhood" << std::endl;
94 Point p1( -M, -M, -M );
97 K.
init( p1, p2,
true );
100 DigSurface dsurf(
new DigitalSurfaceContainer(
K, aSet ) );
101 trace.
info() <<
"[OK]" <<
" Sphere has " << dsurf.size() <<
" vertices/surfels"
106 std::map< SCell, RealPoint > v2n;
107 for (
auto v : dsurf )
111 BFSVisitor bfv( dsurf, v );
112 while( ! bfv.finished() )
114 auto node = bfv.current();
115 if ( KN < node.second )
break;
116 auto surfel = node.first;
119 nv[ k ] =
K.
sDirect( surfel, k ) ? 1.0 : -1.0;
130 const double area_true = 4.0 * M_PI * R * R;
131 double area_averaged = 0.0;
132 double area_corrected = 0.0;
133 for (
auto v : dsurf )
137 area_corrected += fabs( v2n[ v ][ k ] );
138 area_averaged += 1.0 / v2n[ v ].norm( RealPoint::L_1 );
140 trace.
info() <<
"- true area = " << area_true << std::endl;
141 trace.
info() <<
"- corrected area = " << area_corrected << std::endl;
142 trace.
info() <<
"- averaged area = " << area_averaged << std::endl;
Aim: This class is useful to perform a breadth-first exploration of a graph given a starting point or...
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as the boundary of a given...
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
Dimension sOrthDir(const SCell &s) const
Given a signed surfel [s], returns its orthogonal direction (ie, the coordinate where the surfel is c...
bool sDirect(const SCell &p, Dimension k) const
Return 'true' if the direct orientation of [p] along [k] is in the positive coordinate direction.
PointVector< dim, double, std::array< double, dim > > getNormalized() const
Aim: A utility class for constructing different shapes (balls, diamonds, and others).
void beginBlock(const std::string &keyword="")
DGtal::uint32_t Dimension
HyperRectDomain< Space > Domain
References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::PointVector< dim, TEuclideanRing, TContainer >::getNormalized(), DGtal::Trace::info(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), K, DGtal::KhalimskySpaceND< dim, TInteger >::sDirect(), DGtal::KhalimskySpaceND< dim, TInteger >::sOrthDir(), and DGtal::trace.