opencv形态膨胀过滤器作为最大的过滤器 [英] opencv morphological dilation filter as maximum filter

查看:289
本文介绍了opencv形态膨胀过滤器作为最大的过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

像中值滤波器的定义一样,我可以定义最大滤波器,就像本地窗口一样,例如, dst(x,y)= max(3x3局部窗口像素)

但是我在opencv中找不到这样的过滤器,最接近的是dilate函数



然后,我使用默认配置dilate函数,但结果是不正确的
比较我的蛮力执行的最大过滤器。



我发现对于3x3的情况,等效的扩张配置是使用1x1矩形结构元素,即

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



我的问题是:


  1. 对于我来说,我认为一个结构元素相当于一个本地窗口,但现在局部窗口的大小只有1x1像素?如果我的最大过滤器的本地窗口扩大(例如5x5,7x7)怎么办?是否有最大的过滤器和膨胀过滤器之间的任何关系?$ / $>


  2. 解决方案

    在Mathematica中的实现示例:
    $ b


    $ b 但是 Dilation [] 也可以接受一个结构化的内核:


    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?

    解决方案

    An implementation example in Mathematica:

    But Dilation[ ] also accepts a structuring kernel:

    这篇关于opencv形态膨胀过滤器作为最大的过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆