opencv morphological dilation filter as maximum filter

眉间皱痕 提交于 2019-12-08 05:30:17

问题


Like the definition of median filter, I can define "maximum filter" as for a local window

e.g. dst(x,y) = max(3x3 local window pixels)

But I cannot find such a filter in opencv, the closest one is "dilate" function

Then I use the default configuration of "dilate" function, but the result is incorrect compare to my brute force implementation of the maximum filter.

I found that for 3x3 case, the equivalent dilate configuration is to use a 1x1 rectangular structure element, that is

dilate(src, dst, getStructuringElement(MORPH_RECT, Size(1,1)))

My questions are:

  1. It seemed counter-intuitive for me that I thought a structure element is equivalent to a local window. But now the local window's size is only 1x1 pixel?

  2. What if my maximum filter's local window expands(e.g. 5x5, 7x7)? Is there any relationship between the maximum filter and dilation filter?


回答1:


An implementation example in Mathematica:

But Dilation[ ] also accepts a structuring kernel:



来源:https://stackoverflow.com/questions/5696088/opencv-morphological-dilation-filter-as-maximum-filter

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