拉普拉斯和高斯滤波器
我正在尝试进行一些图像处理,并且想应用 LoG 内核。我知道这个公式,它是:
但我不明白如何用这个公式获取内核矩阵。根据我所读到的内容,我有一个 nxn 矩阵,我将这个公式应用于该矩阵中的每个单元格,但首先该矩阵中的起始值应该是什么。
另外,我对拉普拉斯过滤器有同样的问题。我知道公式,即:
而且,根据我所读到的内容,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 :
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:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基本上,我们只是从连续空间进入离散空间。连续时间(空间)中的一阶导数类似于离散时间(空间)中的一阶差分。要计算离散时间信号的一阶差分,请对信号进行卷积
[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