Thinning algorithms reduce a pixel-discrete binary structure to its skeleton.
cv_algorithms
provides an easy-to-use implementation for Python & OpenCV. Due to it being implemented in C, it is suitable for high-performance applications.
Both the Zhang-Suen and the Guo-Hall variants are implemented. They only differ in some details of the calculation.
For a simple example source code see this file.
This example has been generated using the example script linked to above.
Input (generated with GIMP fractal generator):
Zhang-Suen output:
Guo-Hall output: