#include <iostream>
#include "ConfigExamples.h"
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/helpers/Shortcuts.h"
#include "DGtal/helpers/ShortcutsGeometry.h"
#include "DGtal/dec/ATSolver2D.h"
#include "DGtal/dec/DiscreteExteriorCalculusFactory.h"
Go to the source code of this file.
|
int | main (int argc, char **argv) |
|
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
- 2019/06/09
An example file named exampleSurfaceATNormals.
This file is part of the DGtal library.
Definition in file exampleSurfaceATNormals.cpp.
◆ main()
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
[AT-surface-init]
[AT-surface-init]
[AT-surface-calculus]
[AT-surface-calculus] [AT-surface-solve]
[AT-surface-solve]
[AT-surface-getU2]
[AT-surface-getU2]
[AT-surface-getV0]
[AT-surface-getV0]
Definition at line 48 of file exampleSurfaceATNormals.cpp.
57 const double alpha_at = 0.1;
58 const double lambda_at = 0.01;
59 const double e1 = 2.0;
60 const double e2 = 0.25;
61 const double er = 2.0;
63 const string volfile = argc > 1 ? argv[ 1 ] : examplesPath +
"samples/Al.100.vol";
64 const double threshold = argc > 2 ? atof( argv[ 2 ] ) : 0.5;
65 trace.
beginBlock (
"Load vol file -> build digital surface -> estimate II normals." );
82 const auto calculus = CalculusFactory::createFromNSCells<2>( surfels.begin(), surfels.end() );
86 at_solver.initInputVectorFieldU2( ii_normals, surfels.cbegin(), surfels.cend() );
87 at_solver.setUp( alpha_at, lambda_at );
88 at_solver.solveGammaConvergence( e1, e2, er );
94 auto at_normals = ii_normals;
95 at_solver.getOutputVectorFieldU2( at_normals, surfels.cbegin(), surfels.cend() );
98 std::transform( surfels.cbegin(), surfels.cend(), positions.begin(),
99 [&] (
const SH3::SCell& c) { return embedder( c ); } );
101 for (
size_t i = 0; i < surfels.size(); i++ )
102 colors[ i ] =
SH3::Color( (
unsigned char) 255.0*fabs( at_normals[ i ][ 0 ] ),
103 (
unsigned char) 255.0*fabs( at_normals[ i ][ 1 ] ),
104 (
unsigned char) 255.0*fabs( at_normals[ i ][ 2 ] ) );
105 std::transform( surfels.cbegin(), surfels.cend(), positions.begin(),
106 [&] (
const SH3::SCell& c) { return embedder( c ); } );
109 "output-surface.obj" );
111 "output-surface-at-normals.obj" );
113 "output-vf-at-normals.obj",
117 at_solver.getOutputScalarFieldV0( features, linels.cbegin(), linels.cend(),
122 for (
size_t i = 0; i < linels.size(); i++ )
124 if ( features[ i ] < threshold )
126 const Cell linel = linels[ i ];
130 f0.push_back( uembedder( p0 ) );
131 f1.push_back( uembedder( p1 ) - uembedder( p0 ) );
135 "output-features.obj",
References DGtal::Trace::beginBlock(), DGtal::Shortcuts< TKSpace >::defaultParameters(), DGtal::ShortcutsGeometry< TKSpace >::defaultParameters(), DGtal::Trace::endBlock(), DGtal::Shortcuts< TKSpace >::getCellEmbedder(), DGtal::Shortcuts< TKSpace >::getCellRange(), DGtal::ShortcutsGeometry< TKSpace >::getIINormalVectors(), DGtal::Shortcuts< TKSpace >::getKSpace(), DGtal::ATSolver2D< TKSpace, TLinearAlgebra >::getOutputScalarFieldV0(), DGtal::ATSolver2D< TKSpace, TLinearAlgebra >::getOutputVectorFieldU2(), DGtal::Shortcuts< TKSpace >::getSCellEmbedder(), DGtal::Shortcuts< TKSpace >::getSurfelRange(), DGtal::ATSolver2D< TKSpace, TLinearAlgebra >::initInputVectorFieldU2(), K, DGtal::Shortcuts< TKSpace >::makeBinaryImage(), DGtal::Shortcuts< TKSpace >::makeDigitalSurface(), DGtal::ATSolver2D< TKSpace, TLinearAlgebra >::Maximum, DGtal::Color::Red, DGtal::Shortcuts< TKSpace >::saveOBJ(), DGtal::Shortcuts< TKSpace >::saveVectorFieldOBJ(), DGtal::ATSolver2D< TKSpace, TLinearAlgebra >::setUp(), DGtal::ATSolver2D< TKSpace, TLinearAlgebra >::solveGammaConvergence(), DGtal::trace, DGtal::KhalimskySpaceND< dim, TInteger >::uDirs(), and DGtal::KhalimskySpaceND< dim, TInteger >::uIncident().
static RealVectors getIINormalVectors(CountedPtr< BinaryImage > bimage, const SurfelRange &surfels, const Parameters ¶ms=parametersGeometryEstimation()|parametersKSpace())
static CanonicCellEmbedder< KSpace > getCellEmbedder(const KSpace &K)
LightDigitalSurface::Cell Cell
static CellRange getCellRange(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Dimension k)
Structure representing an RGB triple with alpha component.
Z3i::RealVector RealVector
std::vector< Color > Colors
DGtal::uint32_t Dimension
static CountedPtr< DigitalSurface > makeDigitalSurface(CountedPtr< TPointPredicate > bimage, const KSpace &K, const Parameters ¶ms=parametersDigitalSurface())
void beginBlock(const std::string &keyword="")
Aim: This class is used to simplify shape and surface creation. With it, you can create new shapes an...
static bool saveVectorFieldOBJ(const RealPoints &positions, const RealVectors &vf, double thickness, const Colors &diffuse_colors, std::string objfile, const Color &ambient_color=Color(32, 32, 32), const Color &diffuse_color=Color(200, 200, 255), const Color &specular_color=Color::White)
std::vector< RealVector > RealVectors
ShortcutsGeometry< Z3i::KSpace > SHG3
Shortcuts< Z3i::KSpace > SH3
static Parameters defaultParameters()
Aim: This class solves Ambrosio-Tortorelli functional on a two-dimensional digital space (a 2D grid o...
std::vector< Scalar > Scalars
Aim: This class provides static members to create DEC structures from various other DGtal structures.
static CanonicSCellEmbedder< KSpace > getSCellEmbedder(const KSpace &K)
Aim: This class is used to simplify shape and surface creation. With it, you can create new shapes an...
LightDigitalSurface::SCell SCell
DirIterator uDirs(const Cell &p) const
Given an unsigned cell [p], returns an iterator to iterate over each coordinate the cell spans.
std::vector< RealPoint > RealPoints
static KSpace getKSpace(const Point &low, const Point &up, Parameters params=parametersKSpace())
LightDigitalSurface::Surfel Surfel
Cell uIncident(const Cell &c, Dimension k, bool up) const
Return the forward or backward unsigned cell incident to [c] along axis [k], depending on [up].
Aim: Implements basic operations that will be used in Point and Vector classes.
static Parameters defaultParameters()
static bool saveOBJ(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > digsurf, const TCellEmbedder &embedder, const RealVectors &normals, const Colors &diffuse_colors, std::string objfile, const Color &ambient_color=Color(32, 32, 32), const Color &diffuse_color=Color(200, 200, 255), const Color &specular_color=Color::White)
static SurfelRange getSurfelRange(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Parameters ¶ms=parametersDigitalSurface())
static CountedPtr< BinaryImage > makeBinaryImage(Domain shapeDomain)
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...