How can I compute Dilution and closure of image?

Suppose we have image A and the structuring element B from figure 2. How can I compute A dilated by B and A closed by B?

Hi @Robinson_Chera,
It depends on the software package you want to use.
In Python, OpenCV has function for such erosion/dilation, while closing operation is an erosion followed by dilation (or the opposite I don’t remember). See OpenCV: Eroding and Dilating

You can see that there is an argument to precise the structuring element (B in your case).
I guess #scikit-image can do it too, and #knime too.

Hello, thanks for the reply! I just wanted to know the mathematical part, if I would know this I think it will be much easier for me to implement it in Python

I have this code but idk how to apply the math on paper for my image…

from skimage import filters
import numpy as np
grad_x = filters.sobel_h(input_image)
grad_y = filters.sobel_v(input_image)
edge_magnitude = np.sqrt(grad_x**2+grad_y**2)