This is a Matlab program for doing morphological operations on a image , efficient Dilation, Erosion, Opening, and Closing Algorithms
just copy to the matlabs current folder and run it
more information is in the blog http://servforu.blogspot.com/2014/05/efficient-dilation-erosion-opening-and.html