Adaptive threshold

Adds adaptiveThreshold method. Needed this to port a python example.