What's the best way to automatically figure out the best threshold for converting a grayscale image to black and white? I can figure out pretty good threshold values by hand, but I would like to automate choosing the threshold value.
Edit: I've been reading a bit about this problem, and by looking at the histogram for the image can help, e.g. if the image has a bi-modal histogram then choosing a threshold between the modes seems to be reasonably. However, for multi-modal, or flat histograms, it appears more complicated. So I think I have some more reading to do. Thanks to everyone who replied!