Efficient Dilation, Erosion, Opening, and Closing Algorithms