add autoTreshold

I equipped some functions to determine proper threshold automatically. This will lead to better results in some pictures. Please see the picture below for the comparison.
This is the first time for me to do pull request. So, I would appreciate it if you wouldn't hesitate to blame me when you find some my behavior impolite.
Thank you.
![threshold](https://f.cloud.github.com/assets/3764516/2329436/84c41636-a418-11e3-9c3f-ebd4006b11a7.jpg)