Adding tests for thresholding.

I have added the doctests and some 2d cases.