How do you do mathematical morphology manually? If you have a kernel or structuring element B1 do you move the origin of B1 to every pixel in the matrix A1 and see if it is a perfect match, partial match or no match? I am not sure if this is correct? And in my case "Internally, it defined dilation as follows: a 0 valued pixel is changed to 1 if at least one of the eight neighbors has value1. Conversely, we may define ersion as changing a 1 valued pixel to 0 if at least one of the eight neighbors of the origin has value 0"