Otsu thresholding (algorithm adapted from Wikipedia)
Otsu's method
Fixes compilation warnings and the thresholding example