# Erode/Erosion on Matrix

a = [1 1 1 0 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0 0;
1 1 0 0 1 0 1 1 1 0 1 1 1 0 0 1 1 1 0 0;
1 1 1 1 1 1 0 1 1 0 0 1 0 0 0 0 1 0 0 0;
0 0 0 1 1 0 1 1 1 0 1 0 1 0 0 0 0 0 0 0;
0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 1 1 1;
0 0 1 1 1 0 1 1 1 0 1 0 0 0 1 0 0 0 1 1;
1 0 0 0 1 0 1 1 0 1 1 1 0 1 1 1 0 1 0 1;
1 1 0 1 1 1 1 0 1 0 1 0 0 0 1 0 0 0 0 1;
1 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 1 1 1 0;
0 0 0 0 0 0 1 1 1 0 0 1 1 1 0 0 0 1 0 0;
0 0 0 0 0 1 0 1 0 0 0 1 1 1 0 0 1 1 1 0;
0 1 1 0 1 0 1 1 0 0 0 1 1 1 1 0 1 1 1 0;
1 0 0 1 0 0 0 0 1 1 1 0 0 1 0 0 0 0 0 0;
1 1 1 0 0 0 0 0 1 1 1 0 1 1 1 0 0 0 0 0;
0 1 1 1 0 1 0 0 1 1 1 0 0 1 1 0 0 1 1 1;
0 1 1 0 0 1 0 0 1 1 1 0 1 1 1 0 0 1 1 1;
0 0 0 0 1 1 1 0 0 0 1 0 0 0 1 0 1 1 1 1;
1 1 0 0 0 1 1 0 0 1 1 1 0 0 0 1 0 0 1 0;
1 1 1 0 0 1 0 0 0 1 1 1 0 0 1 1 1 0 0 0;
1 1 0 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0 0 0];

b = [1 1 1;
0 1 0;
1 1 1];

I never heard the term ‘matrix erosion’ before, but it is an image processing term. Searching ‘python matrix erosion’ indicates that one can do it with either opencv or numpy.