Topological peak detection in two-dimensional data

A simple Python implementation of the 0-th dimensional persistent homology for 2D images. It is basically a two-dimensional version of the method described in my blog article persistent topology for peak detection.

The implementation uses a union-find data structure instead of the more efficient implemention used for one-dimensional data. The union-find data structure implementation was taken from PADS and sligthly modified.

The related literature is Computational Topology by Herbert Edelsbrunner.1

Update: A related paper on this topic appeared at iDSC2020.

Download

The current version is available on git.sthu.org.

Demonstration

The code has been used for answers to the following two stackoverflow questions:

An ipython notebook is included in the git repository to demonstrate the code. Assume we are given the input of the first stackoverflow question:

Input image

Then the 0-th dimensional persistence diagram looks like this:

Persistence diagram

  1. H. Edelsbrunner and J. Harer, Computational Topology. An Introduction, 2010, ISBN 0-8218-4925-5.