from Grayscale Dilation and Erosion by Luigi Rosa
A very fast implementation.

All files for Grayscale Dilation and Erosion
/gdil.c
/gerod.c
/graydil.m
/grayero.m
/license.txt
/provatempo.m
/readme.txt

Contact us at files@mathworks.com