36#include "DGtal/base/BasicFunctors.h"
37#include "DGtal/topology/CanonicSCellEmbedder.h"
38#include "DGtal/helpers/StdDefs.h"
39#include "DGtal/graph/DistanceBreadthFirstVisitor.h"
40#include "DGtal/topology/DigitalSurface.h"
41#include "DGtal/topology/LightImplicitDigitalSurface.h"
42#include "DGtal/geometry/volumes/distance/LpMetric.h"
43#include "DGtal/io/readers/VolReader.h"
44#include "DGtal/io/viewers/PolyscopeViewer.h"
46#include "DGtal/io/Color.h"
47#include "DGtal/io/colormaps/HueShadeColorMap.h"
48#include "DGtal/images/ImageSelector.h"
49#include "DGtal/images/imagesSetsUtils/SetFromImage.h"
61 std::cerr <<
"Usage: " << argv[ 0 ] <<
" <fileName.vol> <minT> <maxT> <idxP>" << std::endl;
62 std::cerr <<
"\t - displays the Euclidean distance to the specified surfel on the boundary of the shape stored in vol file <fileName.vol>." << std::endl;
63 std::cerr <<
"\t - the shape is defined implicitly: voxel v belongs to the shape iff its value I(v) follows minT < I(v) <= maxT." << std::endl;
64 std::cerr <<
"\t - starts from the <idxP>-th surfel or first one if invalid." << std::endl;
67int main(
int argc,
char** argv )
74 std::string inputFilename = argv[ 1 ];
75 unsigned int minThreshold = atoi( argv[ 2 ] );
76 unsigned int maxThreshold = atoi( argv[ 3 ] );
77 unsigned int idxP = (argc <= 4) ? 0 : atoi( argv[ 4 ] );
80 trace.beginBlock(
"Reading vol file into an image." );
85 minThreshold, maxThreshold);
91 trace.beginBlock(
"Construct the Khalimsky space from the image domain." );
93 bool space_ok = ks.
init(
image.domain().lowerBound(),
94 image.domain().upperBound(),
true );
97 trace.error() <<
"Error in the Khamisky space construction."<<std::endl;
105 MySurfelAdjacency surfAdj(
true );
109 trace.beginBlock(
"Set up digital surface." );
120 for ( idxP = idxP % digSurf.
size(); idxP != 0; --idxP ) ++it;
125 trace.beginBlock(
"Extracting boundary by distance tracking from an initial bel." );
134 typedef MyDistanceVisitor::Node MyNode;
135 typedef MyDistanceVisitor::Scalar MySize;
137 SCellEmbedder embedder( ks );
138 Distance distance(2.0);
139 DistanceToPoint distanceToPoint = std::bind( distance, embedder( bel ), std::placeholders::_1 );
140 VertexFunctor vfunctor( embedder, distanceToPoint );
141 MyDistanceVisitor visitor( digSurf, vfunctor, bel );
143 unsigned long nbSurfels = 0;
145 while ( ! visitor.finished() )
147 node = visitor.current();
151 MySize maxDist = node.second;
156 trace.beginBlock(
"Displaying surface in PolyscopeViewer." );
159 MyDistanceVisitor visitor2( digSurf, vfunctor, bel );
162 std::vector< MyDistanceVisitor::Node > layer;
163 while ( ! visitor2.finished() )
165 MyNode n = visitor2.current();
166 Color c = hueShade( n.second );
167 viewer << c << n.first;
170 trace.info() <<
"nb surfels = " << nbSurfels << std::endl;
67int main(
int argc,
char** argv ) {
…}
Structure representing an RGB triple with alpha component.
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
DigitalSurfaceContainer::SurfelConstIterator ConstIterator
ConstIterator begin() const
Aim: This class is useful to perform an exploration of a graph given a starting point or set (called ...
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.
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as the boundary of an impl...
Aim: implements l_p metrics.
void show() override
Starts the event loop and display of elements.
PointVector< dim, double > RealPoint
static SCell findABel(const KSpace &K, const PointPredicate &pp, unsigned int nbtries=1000)
Aim: Represent adjacencies between surfel elements, telling if it follows an interior to exterior ord...
Aim: Define a new Functor from the composition of two other functors.
DigitalSurface< MyDigitalSurfaceContainer > MyDigitalSurface
DigitalSetBoundary< KSpace, DigitalSet > MyDigitalSurfaceContainer
Z3i this namespace gathers the standard of types for 3D imagery.
KhalimskySpaceND< 3, Integer > KSpace
Space::RealPoint RealPoint
DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: A trivial embedder for signed cell, which corresponds to the canonic injection of cell centroids...
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())