DGtal  1.4.beta
DGtal python binding
Package managers:
Pablo Hernandez-Cerdan, David Coeurjolly

Package Overview

Since release 1.2, DGtal has a partial python binding using pybind11. To install the python package, just use:

pip install dgtal

Then, you can import the module in python:

import dgtal

At this point, only a partial support is available (some base, kernel, image, topology classes). For a complete review of the available tools, have a look to this Pull-Request.

Just a quick example (Euler characteristics and simple point detection on random sets):

import dgtal
import random
Point = dgtal.kernel.Point3D
Domain = dgtal.kernel.DomainZ3i
Set = dgtal._dgtal.kernel.DigitalSetZ3i
dom = Domain( Point(0,0,0), Point(10,10,10))
mySet = Set(dom)
# Random set
for i in range(50*50):
# Digital Object (with topology)
Object = dgtal.topology.Object26_6
Topo = Object.TDigitalTopology
FAdj = Topo.TForegroundAdjacency
BAdj = Topo.TBackgroundAdjacency
fadj = FAdj()
badj = BAdj()
topo = Topo(fadj, badj)
obj = Object(topo,mySet)
#Counting the simple points
for p in mySet:
if obj.isSimple(p):
cptSimple += 1
print("Number of simple points: "+str(cptSimple)+ " / " + str(mySet.size()))
# Cubical Complex
kspace = dgtal.topology.KSpace3D()
ccomplex = dgtal.topology.CubicalComplex3D(kspace)
print("Euler characteristic: "+str(ccomplex.euler()))
Object< DT26_6, DigitalSet > Object26_6
Definition: StdDefs.h:186
MyPointD Point
Definition: testClone2.cpp:383
void insert(VContainer1 &c1, LContainer2 &c2, unsigned int idx, double v)
HyperRectDomain< Space > Domain
for(Domain::ConstIterator it=domain.begin(), it_end=domain.end();it !=it_end;++it,++cnt)