Python implementation (coded entirely in NumPy) of "A Threshold Selection Method from Gray-Level Histograms" (1979) - Otsu's method for autonomous image segmentation.
The algorithm takes a grayscale image as input, and outputs the grayscale threshold maximizing the interclass variance (or equivalently, minimizing the intraclass variance).
In the Jupyter Notebook, I compare my personal implementation to OpenCV's. Moreover, I show how Otsu's method is nothing but a special case of the k-means clustering algorithm proposed by MacQueen in 1967 (more than 10 years earlier!)
otsu_segmentation.py
: Python implementation of the algorithm.
demo.ipynb
: A demonstration and comparison against two state-of-the-art methods.