Python/scipy 中的一维非极大值抑制
你碰巧有一个用Python编写的一维非极大值抑制算法吗?我需要它来使用 scipy 在 Python 中制作 Canny 边缘检测器,该检测器将一维强度向量作为输入。
我在网上浏览了一下,有很多描述 Canny 边缘检测器行为的信息以及一些用 Java 编写的示例,但它们都描述了 2D 边缘检测。
然而 scipy 确实支持 Canny 边缘检测所需的其他算法,即一维的高斯滤波和微分。
提前致谢。
Do you happen to have a 1D non-maximum suppression algorithm written in Python. I need it for making a Canny edge detector in Python using scipy that takes as input a 1D intensity vector.
I've looked around on the web and there is a lot of information describing the behavior of the Canny edge detector and some examples written in Java but they all describe edge detection in 2D.
However scipy does support the other algorithms needed for the Canny edge detection, namely the Gaussian filtering and differentiation for 1D.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你的意思是最大过滤器吗?如果是这样,请查看 scipy.ndimage.maximum_filter1d
作为一个简单的例子:
这会产生:
Do you just mean a maximum filter? If so, have a look at scipy.ndimage.maximum_filter1d
As a quick example:
This yields:
我假设你的数据不是周期性的。让我给你一些伪代码,希望这已经足够了。
-- 比较数据
-- 您正在寻找差异中的符号变化。对于麦克斯来说,这将是从积极到消极;零是一个特殊情况。 numpy.sign() 为您提供负值、零值和正值的 -1、0、1 中每个值的符号。
-- 您可以再次比较 -- 您正在寻找 -2 和 -1 或最小抑制 2 和 1。正确处理边界。
祝你好运,E
干杯,E
I assume your data is not periodic. Let me give you some pseudocode and hopefully that is enough.
-- diff the data
-- you are looking for sign changes in the diff. For Max that would be going from positive to negative; zero is a special case. numpy.sign() gives you the sign of each value in -1, 0, 1 for negative, zero and positive values.
-- You can diff again -- you are looking for -2 and -1 or for min suppression 2 and 1. Handle the boundaries properly.
Good luck, E
Cheers, E
如果您的输入数据是变量“信号”,那么您需要的结果可以通过以下方式给出:(
使用 Numpy 函数)
If your input data is the variable "signal", then the result you need can be given by:
(using Numpy functions)