This is pretty standard image processing techniques, which you can streamline yourself. Not sure if there exists out-of-the-box solutions, but you can easily create your own with for example scikit-image (python).
Here are some selected functions.
Opening: http://scikit-image.org/docs/stable/api/skimage.morphology.h...
Closing: http://scikit-image.org/docs/stable/api/skimage.morphology.h...
Dilate: http://scikit-image.org/docs/stable/api/skimage.morphology.h...
I recommend starting at the user guide: http://scikit-image.org/docs/stable/user_guide.html