35#include <QImageReader>
37#include "DGtal/base/BasicFunctors.h"
38#include "DGtal/topology/CanonicSCellEmbedder.h"
39#include "DGtal/helpers/StdDefs.h"
40#include "DGtal/graph/DistanceBreadthFirstVisitor.h"
41#include "DGtal/topology/DigitalSurface.h"
42#include "DGtal/topology/LightImplicitDigitalSurface.h"
43#include "DGtal/geometry/volumes/distance/LpMetric.h"
44#include "DGtal/io/readers/VolReader.h"
45#include "DGtal/io/viewers/Viewer3D.h"
47#include "DGtal/io/Color.h"
48#include "DGtal/io/colormaps/HueShadeColorMap.h"
49#include "DGtal/images/ImageSelector.h"
50#include "DGtal/images/imagesSetsUtils/SetFromImage.h"
61void usage(
int,
char** argv )
63 std::cerr <<
"Usage: " << argv[ 0 ] <<
" <fileName.vol> <minT> <maxT> <idxP>" << std::endl;
64 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;
65 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;
66 std::cerr <<
"\t - starts from the <idxP>-th surfel or first one if invalid." << std::endl;
69int main(
int argc,
char** argv )
76 std::string inputFilename = argv[ 1 ];
77 unsigned int minThreshold = atoi( argv[ 2 ] );
78 unsigned int maxThreshold = atoi( argv[ 3 ] );
79 unsigned int idxP = (argc <= 4) ? 0 : atoi( argv[ 4 ] );
87 minThreshold, maxThreshold);
93 trace.
beginBlock(
"Construct the Khalimsky space from the image domain." );
95 bool space_ok = ks.
init( image.domain().lowerBound(),
96 image.domain().upperBound(),
true );
99 trace.
error() <<
"Error in the Khamisky space construction."<<std::endl;
107 MySurfelAdjacency surfAdj(
true );
122 for ( idxP = idxP % digSurf.
size(); idxP != 0; --idxP ) ++it;
127 trace.
beginBlock(
"Extracting boundary by distance tracking from an initial bel." );
136 typedef MyDistanceVisitor::Node MyNode;
137 typedef MyDistanceVisitor::Scalar MySize;
139 SCellEmbedder embedder( ks );
140 Distance distance(2.0);
141 DistanceToPoint distanceToPoint = std::bind( distance, embedder( bel ), std::placeholders::_1 );
142 VertexFunctor vfunctor( embedder, distanceToPoint );
143 MyDistanceVisitor visitor( digSurf, vfunctor, bel );
145 unsigned long nbSurfels = 0;
147 while ( ! visitor.finished() )
149 node = visitor.current();
153 MySize maxDist = node.second;
159 QApplication application(argc,argv);
163 MyDistanceVisitor visitor2( digSurf, vfunctor, bel );
168 std::vector< MyDistanceVisitor::Node > layer;
169 while ( ! visitor2.finished() )
171 MyNode n = visitor2.current();
172 Color c = hueShade( n.second );
177 viewer << Viewer3D<>::updateDisplay;
178 trace.
info() <<
"nb surfels = " << nbSurfels << std::endl;
180 return application.exec();
Structure representing an RGB triple with alpha component.
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...
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.
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.
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as the boundary of an impl...
Aim: implements l_p metrics.
Aim: Implements basic operations that will be used in Point and Vector classes.
Component Coordinate
Type for Point elements.
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...
void beginBlock(const std::string &keyword="")
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
Aim: Define a new Functor from the composition of two other functors.
DigitalSurface< MyDigitalSurfaceContainer > MyDigitalSurface
DigitalSetBoundary< KSpace, DigitalSet > MyDigitalSurfaceContainer
Space::RealPoint RealPoint
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)
Modifier class in a Display3D stream. Useful to choose your own mode for a given class....
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
std::string className() const
Return the style name used for drawing this object.
static ImageContainer importVol(const std::string &filename, const Functor &aFunctor=Functor())
ImageContainerBySTLVector< Domain, Value > Image