ENH Add generalized Bernsen thresholding

This allows the user to specify their own structuring element.