拉普拉斯和高斯滤波器

发布于 2024-09-28 03:14:22 字数 426 浏览 5 评论 0原文

我正在尝试进行一些图像处理,并且想应用 LoG 内核。我知道这个公式,它是:

alt text

但我不明白如何用这个公式获取内核矩阵。根据我所读到的内容,我有一个 nxn 矩阵,我将这个公式应用于该矩阵中的每个单元格,但首先该矩阵中的起始值应该是什么。

另外,我对拉普拉斯过滤器有同样的问题。我知道公式,即:

alt text

而且,根据我所读到的内容,3 x 3 过滤器应该是矩阵:

x = [1 1 1; 1 -4 1; 1 1 1]

但是您能否告诉我如何应用该公式以获得矩阵,或者至少向我指示如何应用该公式的教程。

I am trying to do some image processing and I would like to apply the LoG kernel. I know the formula, which is :

alt text

But I didn't understand how to obtain the kernel matrix with this formula. From what I have read, I have a matrix of n x n and I apply this formula to every cell in that matrix, but what should be the starting values within that matrix in the first place.

Also, I have the same question with the Laplacian filer. I know the formula, which is:

alt text

and also, from what I have read, the 3 x 3 filter should be the matrix:

x = [1 1 1; 1 -4 1; 1 1 1]

but can you please tell me how to apply the formula in order to obtain the matrix, or at least indicate me a tutorial of how to apply this.

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

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

发布评论

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

评论(1

坦然微笑 2024-10-05 03:14:22

基本上,我们只是从连续空间进入离散空间。连续时间(空间)中的一阶导数类似于离散时间(空间)中的一阶差分。要计算离散时间信号的一阶差分,请对信号进行卷积 [1 -1]。要计算第二个差异,您可以将信号与 [1 -2 1] 进行卷积(即 [1 -1] 与其自身进行卷积,或者等效地将信号与[1 -1] 两次)。

要计算二维的第二个差异,请将输入图像与问题中提到的矩阵进行卷积。这意味着您采用 3×3 掩码(即您提到的矩阵),将所有九个数字与图像中的九个像素相乘,然后将乘积相加以获得一个输出像素。然后将蒙版向右移动,然后再做一次。每次移位将产生一个输出像素。您可以在整个图像上执行此操作。

要获得高斯滤波器的掩码,只需对任意西格玛的二维高斯函数进行采样即可。

这可能会有所帮助:卷积矩阵高斯滤波器

Basically, we are just going from continuous space to discrete space. The first derivative in continuous time (space) is analogous to the first difference in discrete time (space). To compute the first difference of a discrete-time signal, you convolve [1 -1] over the signal. To compute the second difference, you convolve a signal with [1 -2 1] (which is [1 -1] convolved with itself, or equivalently, convolving the signal with [1 -1] twice).

To calculate the second difference in two dimensions, you convolve the input image with the matrix you mentioned in your question. That means that you take the 3-by-3 mask (i.e, the matrix you mentioned), multiply all nine numbers with nine pixels in the image, and sum the products to get one output pixel. Then you shift the mask to the right, and do it again. Each shift will produce one output pixel. You do that across the entire image.

To get the mask for a Gaussian filter, just sample the two-dimensional Gaussian function for any arbitrary sigma.

This may help: convolution matrix, Gaussian filter

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