I looked at this link: http://en.wikipedia.org/wiki/Erosion_(morphology)#Grayscale_erosion

I can understand that when you look at a pixel, with that structuring element, all pixel values around the origin need to be 1 in order for the pixel in question to be 1.

However, how would this binary erosion work if my structuring element was:

0 1 0
1 1 1
0 1 0

To rephrase the question. Would every pixel that lies on the cross need to be 1 in order for the origin pixel in question to be 1?

有帮助吗?

解决方案

Simply put, yes. If all of the pixels in the structuring element that are 1 are touching object pixels, the output of the filter at the centre of the mask is 1. If any pixel that is 1 in the mask is not touching an object (a.k.a. they're touching a pixel that is 0), the output of the filter at the centre of the mask is zero.

As an example, suppose your structuring element was like you stated

0 1 0 
1 1 1
0 1 0

Let's say our image looks like this:

0 1 0 0 0 1
1 1 1 1 0 1
0 1 0 1 0 0

Let's assume for the moment we need to contain our structuring element within the image. As such, we have four sliding neighbourhoods we need to consider. As such, if we use our structuring element and slide from left to right, the output of the filter will affect the second row and the second, third, fourth and fifth columns. We will ignore the borders and assume they're all zero.

The output of the filter at row 2, column 2 will be 1 as every pixel in the structuring element touches an object pixel. If you slide over to the next window, the structuring element has elements in the mask that are not touching object pixels. Specifically the north and south point, so the output is 0. Sliding over to the right again, the north and east points have pixels that are not touching object pixels as dictated by the mask, and so the output is zero again. Finally, the fifth column has points that are not touching pixels in the north, the middle and the south of the structuring element, and the output is zero yet again. As such, the output should be:

0 0 0 0 0 0
0 1 0 0 0 0
0 0 0 0 0 0

Make sense?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top