How to get the biggest object? Mmmmm,a visual object can range from simple to complex, I bet that code should be used in the context in which it was designed, don't expect that code to find the center pixel of a face, for example.
Try using simple images, more like synthesized images unlike noisy images such as the leaf from web cameras or digital cameras. Most of the current computer vision algorithms I have come across are prone to noise and hence are more suited to what are known as "toy problems".
If you need to use real world imagery then your app need to do a lot more of preprocessing to extract relevant features and some knowledge about possible or predefined objects need to be used as prototypes in more complex situations.