vkiller -3 Newbie Poster

I have a program to write that can binarize a gray-level image based on the assumption that the image has a bimodal histogram. The code should report both the binarized image and the optimal threshold value. Assume that foreground takes a value of 1 and the background a value of 0 in the binary image. Also assume that foreground objects are darker than background objects in the input gray-level image.

Any ideas? Anyone?