高斯模糊和卷积核
我不明白什么是卷积核以及如何将卷积矩阵应用于图像中的像素(我说的是对图像进行高斯模糊操作)。
我还可以获得有关如何为高斯模糊操作创建内核的解释吗?
我正在阅读这篇文章,但我似乎无法理解事情是如何完成的......
感谢任何人谁花时间向我解释这一点:),
ExtremeCoder
I do not understand what a convolution kernel is and how I would apply a convolution matrix to pixels in an image (I am talking about doing a Gaussian Blur operation on an image).
Also could I get an explanation on how to create a kernel for a Gaussian Blur operation?
I am reading this article but I cannot seem to understand how things are done...
Thanks to anyone who takes time to explain this to me :),
ExtremeCoder
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
基本思想是图像的新像素是通过靠近它的像素的加权平均值创建的(想象一下在像素周围画一个圆圈)。
对于图像中的每个像素,您将在该像素周围创建一个小正方形。假设您取一个像素旁边的 8 个邻居(包括对角线,尽管这里并不重要),然后我们执行加权平均以获得中间像素。
在高斯模糊的情况下,它分解为两个一维操作。对于每个像素,仅取行方向上邻近像素的一定数量的像素。将像素值乘以根据高斯分布计算的权重(或者如果您这样做是为了视觉效果而不是出于科学原因,则权重可以是任何看起来不错的东西)并将它们相加。另一种看待它的方法是像素构成一个向量,权重构成一个向量,然后你将得到点积。在列方向上重复此过程作为单独的过程。
The basic idea is that the new pixels of the image are created by an weighted average of the pixels close to it (imagine drawing a circle around the pixel).
For each pixel in the image you are going to create a little square around the pixel. Lets say you take the 8 neighbors next to a pixel (including diagonals even though do not matter here), and we perform a weighted average to get the middle pixel.
In the Gaussian blur case it breaks down to two one dimensional operations. For each pixel take the some amount of pixels next to a pixel in the row direction only. Multiply the pixel values time the weights computed from the Gaussian distribution (or if you are doing this for an visual effect and not for a scientific reason, the weights can anything that looks good) and sum them up. Another way to look at it is the pixel make a vector and the weights make a vector and your are taking the dot product. Repeat this process in the column direction as a separate pass.
卷积核是一个值矩阵,指定像素的邻域如何影响最终图像中该像素的状态。 此处对基础知识进行了合理的描述。高斯模糊是一种卷积函数,它使用一个非常丑陋的(您已经看到维基百科页面)函数来计算卷积核以传递图像。您将在该维基百科页面中找到高斯内核的示例。
其中所有数学运算的目的是产生一种柔和的模糊效果,类似于放置在观看者和图像之间的网状屏幕产生的散射图案。您可以将高斯的“大小”(标准差)视为与图像和屏幕之间的距离有关。
A convolution kernel is a matrix of values that specify how the neighborhood of a pixel contribute to that pixel's state in the final image. There's a fair description of the basics here. A gaussian blur is a convolution function that uses a really ugly (you've seen the wikipedia page) function to compute a convolution kernel to pass over the image. You'll find an example kernel for a gaussian in that wikipedia page.
The point of all the math in there is to produce a soft blur that resembles the scatter pattern produced by a mesh screen placed between the viewer and the image. You can think of the 'size' (the standard deviation) of the gaussian as being related to the distance between the image and the screen.
如果您不想自己计算全部内容(像我一样),这是一个很棒的工具:
http://www.embege.com/gauss/
编辑
由于该链接现在似乎已损坏,因此这里有一个 archive.org 的链接:
http://web.archive.org/web/20150217075657 /http://www.embege.com/gauss
Here's an awesome tool, if you don't want to calculate it all by yourself (like me):
http://www.embege.com/gauss/
EDIT
Since the link seems to be broken now, here's a link to archive.org:
http://web.archive.org/web/20150217075657/http://www.embege.com/gauss