问题描述
我在GLSL中实现了高斯模糊片段着色器。我理解所有这些背后的主要概念:卷积,使用线性分离x和y,多次传递以增加半径...
I've implemented a gaussian blur fragment shader in GLSL. I understand the main concepts behind all of it: convolution, separation of x and y using linearity, multiple passes to increase radius...
我仍然有几个问题:
sigma和radius之间的关系是什么?
我读过sigma相当于radius,我不知道sigma是如何用像素表示的。或者半径只是sigma的名称,与像素无关?
I've read that sigma is equivalent to radius, I don't see how sigma is expressed in pixels. Or is "radius" just a name for sigma, not related to pixels?
如何选择sigma?
考虑到我使用多次传球来增加sigma,我如何选择一个好的sigma来获得我想要的sigma在任何给定的传球?如果得到的sigma等于 sigma的平方和的平方根和sigma等于radius,那么获得任何所需半径的简单方法是什么?
Considering I use multiple passes to increase sigma, how do I choose a good sigma to obtain the sigma I want at any given pass? If the resulting sigma is equal to the square root of the sum of the squares of the sigmas and sigma is equivalent to radius, what's an easy way to get any desired radius?
内核的大小有多大,它与sigma有什么关系?
我见过大多数实现使用5x5内核。对于具有良好质量的快速实现而言,这可能是一个不错的选择,但还有另一个选择另一个内核大小的原因吗? sigma如何与内核大小相关?我应该找到最好的sigma,以便我的内核之外的系数可以忽略不计并正常化吗?
I've seen most implementations use a 5x5 kernel. This is probably a good choice for a fast implementation with decent quality, but is there another reason to choose another kernel size? How does sigma relate to the kernel size? Should I find the best sigma so that coefficients outside my kernel are negligible and just normalize?
推荐答案
sigma和radius之间的关系是什么?
我认为您的条款可以互换,具体取决于您的实施。对于高斯模糊的大多数glsl实现,他们使用sigma值来定义模糊量。在高斯模糊定义中,半径可以被认为是模糊半径。这些术语在像素空间中。
What's the relationship between sigma and radius?
I think your terms here are interchangeable depending on your implementation. For most glsl implementations of Gaussian blur they use the sigma value to define the amount of blur. In the Gaussian blur definition the radius can be considered the 'blur radius'. These terms are in pixel space.
这将定义你的模糊程度想要,它对应于卷积中使用的内核的大小。较大的值会导致更多的模糊。
This will define how much blur you want, which corresponds to the size of the kernel to be used in the convolution. Bigger values will result in more blurring.
NVidia实现使用的内核大小为int(sigma * 3)。
The NVidia implementation uses a kernel size of int(sigma*3).
您可以尝试使用出于性能考虑,较小的内核大小和较高的sigma值。这些是要试验的免费参数,它们定义了用于调制的像素数量以及结果中包含多少相应像素。
You may experiment using a smaller kernel size with higher values of sigma for performance considerations. These are free parameters to experiment with, which define how many pixels to use for modulation and how much of the corresponding pixel to include in the result.
根据sigma值,你需要选择一个相应的内核大小。内核大小将决定卷积过程中要采样的像素数,sigma将定义调整它们的数量。
Based on the sigma value you will want to choose a corresponding kernel size. The kernel size will determine how many pixels to sample during the convolution and the sigma will define how much to modulate them by.
您可能希望发布一些代码以获得更多详细解释。 NVidia在如何构建高斯内核方面有很好的篇章()。
查看例40-1。
You may want to post some code for a more detailed explanation. NVidia has a pretty good chapter on how to build a Gaussian Kernel (http://http.developer.nvidia.com/GPUGems3/gpugems3_ch40.html).Look at Example 40-1.
这篇关于高斯模糊 - 标准偏差,半径和内核大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!