In Matlab you can provide a structuring element to erode/dilate along: https://www.mathworks.com/help/images/ref/strel.html. This would be useful to have here too.