Otsu thresholding (algorithm adapted from Wikipedia)

Otsu thresholding FTW