I have an exercise which is discribed below.
Implement in Matlab a basic algorithm of Dilation and Erosion. The implementation of Matlab for the dilation and erosion of binary images is the formal definition and may be difficult to understand when constructing algorithms for such purposes. Below is the way to create dilatation and erosion algorithms taking into account the basic and intuitive idea of these two operations:
Dilation: take each pixel of the object (with value "1") and set to the value "1" all those pixels belonging to the background that have a connectivity C (C = 4, C = 8, etc) with the pixel of the object. In short, put "1" the pixels of the background neighboring the pixels of the object.
Erosion: take each pixel of the object that has a connectivity C with the pixels of the background and set it to the value "0". In other words, set the pixels of the object to "0" neighboring the background pixels.