Frontiers and boundary of two intersecting balls. The first ball is labelled 1 (red), the second 2 (yellow), their intersection 3 (orange). The frontier between 1 and 0 is displayed in red, the frontier between 2 and 0 is displayed in yellow, the boundary of region 3 is displayed in orange.
#include <iostream>
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/io/readers/VolReader.h"
#include "DGtal/io/DrawWithDisplay3DModifier.h"
#include "DGtal/io/viewers/Viewer3D.h"
#include "DGtal/io/Color.h"
#include "DGtal/io/colormaps/HueShadeColorMap.h"
#include "DGtal/images/ImageSelector.h"
#include "DGtal/images/imagesSetsUtils/SetFromImage.h"
#include "DGtal/shapes/implicit/ImplicitBall.h"
#include "DGtal/shapes/GaussDigitizer.h"
#include "DGtal/shapes/Shapes.h"
#include "DGtal/topology/DigitalSurface.h"
#include "DGtal/topology/ExplicitDigitalSurface.h"
#include "DGtal/topology/helpers/FrontierPredicate.h"
#include "DGtal/topology/helpers/BoundaryPredicate.h"
using namespace Z3i;
int main(
int argc,
char** argv )
{
int radius1 = 6;
EuclideanShape ball1( c1, radius1 );
DigitalShape shape1;
shape1.attach( ball1 );
shape1.init(
RealPoint( -10.0, -10.0, -10.0 ),
int radius2 = 5;
EuclideanShape ball2( c2, radius2 );
DigitalShape shape2;
shape2.attach( ball2 );
shape2.init(
RealPoint( -10.0, -10.0, -10.0 ),
std::cerr << std::endl;
for ( Domain::ConstIterator it =
domain.begin(), it_end =
domain.end();
it != it_end; ++it )
{
label += shape2( *it ) ? 2 : 0;
image.setValue( *it, label );
std::cerr << (int) image( *it );
}
std::cerr << std::endl;
trace.
beginBlock(
"Construct the Khalimsky space from the image domain." );
bool space_ok =
K.init(
domain.lowerBound(),
domain.upperBound(),
true );
if (!space_ok)
{
trace.
error() <<
"Error in the Khamisky space construction."<<std::endl;
return 2;
}
MySurfelAdjacency surfAdj( true );
SCell bel10 =
K.sIncident( vox1, 0,
true );
FSurfelPredicate surfPredicate10(
K, image, 1, 0 );
Frontier frontier10 =
new FrontierContainer(
K, surfPredicate10, surfAdj, bel10 );
SCell bel20 =
K.sIncident( vox2, 0,
false );
FSurfelPredicate surfPredicate20(
K, image, 2, 0 );
Frontier frontier20 =
new FrontierContainer(
K, surfPredicate20, surfAdj, bel20 );
SCell bel32 =
K.sIncident( vox3, 0,
false );
BSurfelPredicate surfPredicate3(
K, image, 3 );
Boundary boundary3 =
new BoundaryContainer(
K, surfPredicate3, surfAdj, bel32 );
trace.
beginBlock(
"Displaying surface in Viewer3D." );
QApplication application(argc,argv);
unsigned int nbSurfels10 = 0;
for ( Frontier::ConstIterator
it = frontier10.begin(), it_end = frontier10.end();
it != it_end; ++it, ++nbSurfels10 )
viewer << *it;
unsigned int nbSurfels20 = 0;
for ( Frontier::ConstIterator
it = frontier20.begin(), it_end = frontier20.end();
it != it_end; ++it, ++nbSurfels20 )
viewer << *it;
unsigned int nbSurfels3 = 0;
for ( Boundary::ConstIterator
it = boundary3.begin(), it_end = boundary3.end();
it != it_end; ++it, ++nbSurfels3 )
viewer << *it;
trace.
info() <<
"nbSurfels10 = " << nbSurfels10
<< ", nbSurfels20 = " << nbSurfels20
<< ", nbSurfels3 = " << nbSurfels3 << std::endl;
viewer << Viewer3D<>::updateDisplay;
return application.exec();
}
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...
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as connected surfels....
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create a ball in nD....
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: The predicate on surfels that represents the frontier between a region and its complementary in ...
Aim: The predicate on surfels that represents the frontier between two regions in an image....
DGtal is the top-level namespace which contains all DGtal functions and types.
boost::uint8_t uint8_t
unsigned 8-bit integer.
Modifier class in a Display3D stream. Useful to choose your own mode for a given class....
ImageContainerBySTLVector< Domain, Value > Image
HyperRectDomain< Space > Domain
PointVector< 3, double > RealPoint