高斯滤波器的拉普拉斯算子的使用
这是 LoG 过滤的公式:
(来源:ed.ac.uk)
另外,在具有 LoG 过滤的应用程序中,我发现该函数仅使用一个参数调用: 西格玛(σ)。 我想尝试使用该公式进行 LoG 过滤(之前的尝试是通过高斯过滤器,然后是具有一定过滤器窗口大小的拉普拉斯过滤器) 但是看着这个公式我无法理解过滤器的大小如何与这个公式联系起来,这是否意味着过滤器的大小是固定的? 你能解释一下如何使用它吗?
This is a formula for LoG filtering:
(source: ed.ac.uk)
Also in applications with LoG filtering I see that function is called with only one parameter:
sigma(σ).
I want to try LoG filtering using that formula (previous attempt was by gaussian filter and then laplacian filter with some filter-window size )
But looking at that formula I can't understand how the size of filter is connected with this formula, does it mean that the filter size is fixed?
Can you explain how to use it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
正如您现在可能已经从其他答案和链接中了解到的那样,LoG 过滤器会检测图像中的边缘和线条。仍然缺少对 σ 是什么的解释。
σ 是滤波器的比例。一像素宽的线条是线条还是噪声? 6 像素宽的线是一条线还是具有两个不同平行边缘的物体?跨 6 或 8 个像素从黑色变为白色的渐变是边缘还是只是渐变?这是你必须决定的事情,σ 的值反映了你的决定 - σ 越大,线条越宽,边缘越平滑,并且忽略更多噪声。
不要混淆滤波器的比例 (σ) 和离散近似值(通常称为模板)的大小。在 Paul 的 链接 中,σ=1.4,模板尺寸为 9。虽然使用 4σ 到 6σ 的模板尺寸通常是合理的,但这两个量是相当独立的。较大的模板可以提供更好的滤波器近似值,但在大多数情况下,您不需要非常好的近似值。
As you've probably figured out by now from the other answers and links, LoG filter detects edges and lines in the image. What is still missing is an explanation of what σ is.
σ is the scale of the filter. Is a one-pixel-wide line a line or noise? Is a line 6 pixels wide a line or an object with two distinct parallel edges? Is a gradient that changes from black to white across 6 or 8 pixels an edge or just a gradient? It's something you have to decide, and the value of σ reflects your decision — the larger σ is the wider are the lines, the smoother the edges, and more noise is ignored.
Do not get confused between the scale of the filter (σ) and the size of the discrete approximation (usually called stencil). In Paul's link σ=1.4 and the stencil size is 9. While it is usually reasonable to use stencil size of 4σ to 6σ, these two quantities are quite independent. A larger stencil provides better approximation of the filter, but in most cases you don't need a very good approximation.
这也让我感到困惑,直到我不得不在一个大学项目中与你做同样的事情时,我才明白你应该用这个公式做什么!
您可以使用此公式生成离散 LoG 滤波器。如果您编写一些代码来实现该公式,则可以生成用于图像卷积的滤波器。要生成 5x5 模板,只需使用 x 和 y 范围从 -2 到 +2 调用代码即可。
这将生成要在 LoG 模板中使用的值。如果您绘制生成的值的图表,您应该会看到此过滤器典型的“墨西哥帽”形状,如下所示:
(来源:ed.ac.uk)
您可以通过更改模板的宽度(大小)和西格玛值(峰的宽度)来微调模板。模板越宽,结果受噪声的影响就越小,因为它将在更广泛的区域内运行。
获得过滤器后,您可以通过将模板与图像进行卷积来将其应用到图像。如果您以前没有这样做过,请查看这几个教程。
Java 小程序教程< /a> 更多数学。
本质上,在每个像素位置,您“放置”卷积模板,以该像素为中心。然后,将周围的像素值乘以模板中相应的“像素”,并将结果相加。这就是该位置的新像素值(通常您还必须标准化(缩放)输出以使其回到正确的值范围)。
下面的代码给出了如何实现这一点的粗略想法。请原谅任何错误/拼写错误等,因为它尚未经过测试。
我希望这有帮助。
This was something that confused me too, and it wasn't until I had to do the same as you for a uni project that I understood what you were supposed to do with the formula!
You can use this formula to generate a discrete LoG filter. If you write a bit of code to implement that formula, you can then to generate a filter for use in image convolution. To generate, say a 5x5 template, simply call the code with x and y ranging from -2 to +2.
This will generate the values to use in a LoG template. If you graph the values this produces you should see the "mexican hat" shape typical of this filter, like so:
(source: ed.ac.uk)
You can fine tune the template by changing how wide it is (the size) and the sigma value (how broad the peak is). The wider and broader the template the less affected by noise the result will be because it will operate over a wider area.
Once you have the filter, you can apply it to the image by convolving the template with the image. If you've not done this before, check out these few tutorials.
java applet tutorials more mathsy.
Essentially, at each pixel location, you "place" your convolution template, centred at that pixel. You then multiply the surrounding pixel values by the corresponding "pixel" in the template and add up the result. This is then the new pixel value at that location (typically you also have to normalise (scale) the output to bring it back into the correct value range).
The code below gives a rough idea of how you might implement this. Please forgive any mistakes / typos etc. as it hasn't been tested.
I hope this helps.
仅出于可视化目的,这里是高斯拉普拉斯(墨西哥帽)小波的简单 Matlab 3D 彩色图。您可以更改 sigma(σ) 参数并查看其对图形形状的影响:
您还可以执行以下操作来比较 sigma 参数对墨西哥帽的影响:
或者简单地使用 Matlab 提供的小波工具箱,如下所示:
我发现这在计算机视觉中实现边缘检测时很有用。虽然不是确切答案,但希望对您有所帮助。
Just for visualization purposes, here is a simple Matlab 3D colored plot of the Laplacian of Gaussian (Mexican Hat) wavelet. You can change the sigma(σ) parameter and see its effect on the shape of the graph:
You could also compare the effects of the sigma parameter on the Mexican Hat doing the following:
Or simply use the Wavelet toolbox provided by Matlab as follows:
I found this useful when implementing this for edge detection in computer vision. Although not the exact answer, hope this helps.
它看起来是一个连续的圆形滤波器,其半径为 sqrt(2) * sigma。如果你想实现这个图像处理,你需要对其进行近似。
这里有一个 sigma = 1.4 的示例: http://homepages.inf .ed.ac.uk/rbf/HIPR2/log.htm
It appears to be a continuous circular filter whose radius is sqrt(2) * sigma. If you want to implement this for image processing you'll need to approximate it.
There's an example for sigma = 1.4 here: http://homepages.inf.ed.ac.uk/rbf/HIPR2/log.htm