Adaptive threshold function using the local mean values

* Very similar to the BoofCV's adaptiveSquare function.