33#include "ConfigExamples.h"
34#include "DGtal/base/Common.h"
35#include "DGtal/helpers/StdDefs.h"
36#include "DGtal/helpers/Shortcuts.h"
37#include "DGtal/helpers/ShortcutsGeometry.h"
38#include "DGtal/dec/ATSolver2D.h"
39#include "DGtal/dec/DiscreteExteriorCalculusFactory.h"
48int main(
int argc,
char** argv )
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() );
87 at_solver.
setUp( alpha_at, lambda_at );
94 auto at_normals = ii_normals;
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",
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",
Aim: This class solves Ambrosio-Tortorelli functional on a two-dimensional digital space (a 2D grid o...
void getOutputScalarFieldV0(ScalarFieldOutput &output, CellRangeConstIterator itB, CellRangeConstIterator itE, CellOutputPolicy policy=CellOutputPolicy::Average)
void setUp(double a, double l)
void initInputVectorFieldU2(const VectorFieldInput &input, SurfelRangeConstIterator itB, SurfelRangeConstIterator itE, bool normalize=false)
bool solveGammaConvergence(double eps1=2.0, double eps2=0.25, double epsr=2.0, bool compute_smallest_epsilon_map=false, double n_oo_max=1e-4, unsigned int iter_max=10)
void getOutputVectorFieldU2(VectorFieldOutput &output, SurfelRangeConstIterator itB, SurfelRangeConstIterator itE)
@ Maximum
compute maximum value at cell vertices
Structure representing an RGB triple with alpha component.
Aim: This class provides static members to create DEC structures from various other DGtal structures.
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
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].
DirIterator uDirs(const Cell &p) const
Given an unsigned cell [p], returns an iterator to iterate over each coordinate the cell spans.
Aim: Implements basic operations that will be used in Point and Vector classes.
Aim: This class is used to simplify shape and surface creation. With it, you can create new shapes an...
static RealVectors getIINormalVectors(CountedPtr< BinaryImage > bimage, const SurfelRange &surfels, const Parameters ¶ms=parametersGeometryEstimation()|parametersKSpace())
static Parameters defaultParameters()
Aim: This class is used to simplify shape and surface creation. With it, you can create new shapes an...
LightDigitalSurface::Surfel Surfel
static KSpace getKSpace(const Point &low, const Point &up, Parameters params=parametersKSpace())
static CellRange getCellRange(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Dimension k)
std::vector< Color > Colors
static SurfelRange getSurfelRange(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Parameters ¶ms=parametersDigitalSurface())
static CanonicSCellEmbedder< KSpace > getSCellEmbedder(const KSpace &K)
static CountedPtr< DigitalSurface > makeDigitalSurface(CountedPtr< TPointPredicate > bimage, const KSpace &K, const Parameters ¶ms=parametersDigitalSurface())
std::vector< RealPoint > RealPoints
std::vector< RealVector > RealVectors
std::vector< Scalar > Scalars
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)
static Parameters defaultParameters()
LightDigitalSurface::SCell SCell
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 CountedPtr< BinaryImage > makeBinaryImage(Domain shapeDomain)
static CanonicCellEmbedder< KSpace > getCellEmbedder(const KSpace &K)
LightDigitalSurface::Cell Cell
void beginBlock(const std::string &keyword="")
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::uint32_t Dimension
ShortcutsGeometry< Z3i::KSpace > SHG3