Erose/Dilate image with zeros structuring element

99封情书 提交于 2019-12-24 00:45:59

问题


If I have a structuring element looks like this one (the origin is at the center of SE):

0  0  0
0  0  0 
0  0  0

If I perform the erosion/dilation on an binary image, the result turns out all 0 or 1. Can someone please explain this one to me? (Check by matlab)
Thank you very much.


回答1:


You have a perfectly valid SE. It is a flat square, commonly accepted and available in every image processing library.

Now, it is important to understand the difference and similarity between flat and non-flat structuring elements (or structuring functions). The similarity is that they operate over a certain neighborhood. For an elementar square element, the neighborhood can be represented by a 3x3 matrix where every element is in the neighborhood of the element (for a rhombus SE, for example, it would be a 3x3 matrix too but the corners wouldn't belong to the neighborhood). In Matlab, this specific neighborhood relation is expressed by ones(3, 3) or simply [1 1 1; 1 1 1; 1 1 1]. The difference between flat and non-flat SE is what makes the strel function in Matlab be the way it is. A non-flat SE implies that it can treat neighbors differently, so it doesn't rely exclusively on the value 0 (the definitions of erosion and dilation are slightly modified to handle this situation). As an example, the square SE is correctly defined in Matlab as strel('arbitrary', ones(3, 3), zeros(3, 3)) (specifying zeros(3, 3) as the second parameter is basically an error, since you are saying you have no neighbors then). On the other hand, a non-flat square can be defined in infinite ways, one of them could be strel('arbitrary', ones(3, 3), [-1 -1 -1; -1 0 -1; -1 -1 -1]).

Summing up, you are most likely using strel incorrectly.



来源:https://stackoverflow.com/questions/14111491/erose-dilate-image-with-zeros-structuring-element

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!