Kittler algorithm
Kittler's algorithm works on approximating the histogram as a bimodal distribution and finds the cutoff
point so as to segment the image into either foreground or background. This works well for one object in a background
and can be extended for multiple objects. Hower the code is implemented to handle one object at a time.
CODE
The code is documented here.