高斯拉普拉斯:它是如何工作的? (OpenCV的) [英] Laplacian of Gaussian: how does it work? (OpenCV)

查看:123
本文介绍了高斯拉普拉斯:它是如何工作的? (OpenCV的)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道它是如何工作的以及如何使用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.

推荐答案

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

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.

输出范围取决于所使用的实际内核,但它总是适合( - max,+ max)范围在零附近 max 是滤波器内核的最大输出幅度;要获得典型输出图像,您需要将其缩放到(0,1)范围(或(0,255)如果您使用的是8位图像)。

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).

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

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.)

这篇关于高斯拉普拉斯:它是如何工作的? (OpenCV的)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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