0

I have the following M_Matrix

M = np.array([[0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1],
              [1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1],
              [1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1],
              [1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1]])

which I want to erose using this structuring element.

st_element = np.ones((3, 3))

The final output sould seem like this

Output = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                   [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0],
                   [0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0],
                   [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]])

My question is: is it possible to do erosion using only numpy_functions ? thanks

Mark Setchell
  • 169,892
  • 24
  • 238
  • 370
ABA
  • 37
  • 5
  • Why only numpy? You can perform a 2D convolution: https://stackoverflow.com/questions/43086557/convolve2d-just-by-using-numpy – mozway Feb 26 '22 at 16:40
  • It does seem a bit masochistic to try to do this without `scikit-image` or at least `scipy`. But really, you should do some research, then try some things, then come back with a question about aspects of the problem you can't crack. I'm not sure why a person would take the time to completely solve this for you when it's a 1-liner in `skimage`. – kwinkunks Feb 26 '22 at 16:59

0 Answers0