My thresholding algorithm for semacode is getting pretty good I think. Check out these results on the classic "Barbara" computer graphics test image.

barbara<p>Next up we have my threshold of the image (adaptive, with an algorithm based on Chow and Kaneko, but the bimodal detector isn’t as good as theirs) </p>barbara<p>Finally, by comparison, a threshold of the image by the person at this page . Mine is better in some places (like the fabric grain and the hand) but not as good in others (like the face). </p>barbara<p>(If you go there you can also see what you get with global threshold, which isn’t as good.) </p>