高斯拉普拉斯算子:它是如何工作的? (OpenCV)

发布于 2024-08-26 10:24:17 字数 176 浏览 4 评论 0原文

有谁知道它是如何工作的以及如何使用 OpenCV 来做到这一点? 拉普拉斯算子可以使用 OpenCV 计算, 但结果并不是我所期望的。 我的意思是,我希望图像在背景区域具有大致恒定的对比度,但它是黑色的,边缘是白色的。即使经过高斯滤波器,也存在很多噪声。 我使用高斯滤波器过滤图像,然后应用拉普拉斯。 我认为我想要的是以不同的方式完成的。

Does anybody know how does it work and how to do it using OpenCV?
Laplacian can be calculated using OpenCV,
but the result is not what I expected.
I mean I expect the image to be approximately constant contrast at background regions, but it is black, and edges are white. There are a lot of noise also, even after gauss filter.
I filter image using gaussian filter and then apply laplace.
I think what I want is done by a different way.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萌梦深 2024-09-02 10:24:17

高斯拉普拉斯算子是一种边缘检测滤波器;在恒定(“背景”)区域中输出为 0,在有对比度的区域中输出为正或负。您在背景区域看到黑色的原因是 OpenCV 只是为您提供原始输出;您所描述的图像类型(背景为灰色,正/负边缘为黑色或白色)是在将输出缩放到适当的范围后生成的。

输出范围根据实际使用的内核而有所不同,但它始终适合零附近的 (-max, +max) 范围,其中 max 是最大输出幅度过滤器内核的;要获得“典型”输出图像,您需要将其缩放到 (0, 1) 范围(如果您使用的是 8 位,则为 (0, 255)图像)。

您可以使用 cvScale 函数执行必要的缩放,以 1/(2*max) 作为缩放因子,并使用 0.5 平移。 (或者对于 8 位图像,使用 255/(2*max) 缩放和 128 移位。)

Laplacian of Gaussian is an edge-detection filter; the output is 0 in constant ('background') regions, and positive or negative where there is contrast. The reason why you're seeing black in the background regions is because OpenCV is just giving you the raw output; the kind of image you're describing (gray on background, with positive / negative edges in black or white) is produced after scaling the output into an appropriate range.

The output range varies depending on the actual kernel used, but it's always going to fit in a (-max, +max) range around zero where max is the maximum output magnitude of the filter kernel; to get the "typical" output image you need to scale that into a (0, 1) range (or (0, 255) if you're using 8-bit images).

You can perform the necessary scaling using the cvScale function, with 1/(2*max) as the scale factor and 0.5 shift. (Or for 8-bit images use 255/(2*max) scale and 128 shift.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文