Loading [MathJax]/extensions/TeX/AMSsymbols.js
DGtal 2.0.0
topology/3dBorderExtraction.cpp

Objects have a border, which are the points which touch the complement in the sense of background adjacency. A border of an object is itself an object, with the same topology as the object.

See also
Border of a digital object
Border extraction visualisation
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/io/readers/VolReader.h"
#include "DGtal/io/viewers/PolyscopeViewer.h"
#include "DGtal/io/Color.h"
#include "DGtal/images/ImageSelector.h"
#include "DGtal/helpers/StdDefs.h"
#include "ConfigExamples.h"
using namespace std;
using namespace DGtal;
int main( int argc, char** argv )
{
typedef SpaceND< 3,int > Z3;
typedef MetricAdjacency< Z3, 2 > Adj18;
Adj6 adj6;
Adj18 adj18;
DT6_18 dt6_18( adj6, adj18, JORDAN_DT );
typedef Z3::Point Point;
typedef Domain::ConstIterator DomainConstIterator;
typedef Object<DT6_18, DigitalSet> ObjectType;
Point p1( -50, -50, -50 );
Point p2( 50, 50, 50 );
Domain domain( p1, p2 );
Point c( 0, 0 );
// diamond of radius 30
DigitalSet diamond_set( domain );
for ( DomainConstIterator it = domain.begin(); it != domain.end(); ++it )
{
if ( (*it - c ).norm1() <= 30 ) diamond_set.insertNew( *it );
}
ObjectType diamond( dt6_18, diamond_set );
// The following line takes almost no time.
ObjectType diamond_clone( diamond );
// Since one of the objects is modified, the set is duplicated at the following line
diamond_clone.pointSet().erase( c );
ObjectType bdiamond = diamond.border(); // one component
ObjectType bdiamond_clone = diamond_clone.border(); // two components
typedef PolyscopeViewer<> MyViewer;
MyViewer viewer;
viewer<< Color(250, 250,250);
viewer << bdiamond_clone;
viewer << bdiamond ;
viewer << ClippingPlane(1,1,0,5);
viewer.show();
return 0;
}
// //
Structure representing an RGB triple with alpha component.
Definition Color.h:77
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
Aim: Describes digital adjacencies in digital spaces that are defined with the 1-norm and the infinit...
Aim: An object (or digital object) represents a set in some digital space associated with a digital t...
Definition Object.h:120
DGtal is the top-level namespace which contains all DGtal functions and types.
STL namespace.
Clipping plane.
Definition Display3D.h:299
DigitalSetByAssociativeContainer< Domain, std::unordered_set< typename Domain::Point > > Type
int main()
Definition testBits.cpp:56
MyPointD Point
Domain domain
HyperRectDomain< Space > Domain
Z2i::DigitalSet DigitalSet
PolyscopeViewer< Space, KSpace > MyViewer