Erosion and Dilation are two operations widely used in image processing. A lot of other operations (opening, closing, skeleton and so on) use them. On "Rafael C. Gonzalez and Richard E. Woods. 2006. Digital Image Processing (3rd Edition). Prentice-Hall, Inc., USA." they are presented in terms of sets, so I decided to implement them using set operations on Python.
This notebook is best viewed in the Google Colab environment: https://colab.research.google.com/drive/1wf8A4VNC6wpOCOvJhrxZ7pZRpU_ykcx9?usp=sharing