2

I am applying a Gaussian filter to a video using ffmpeg's gblur-filter. The filter accepts the sigma option, but does not allow to choose the kernel size. To correctly report on my Gaussian blur usage, I would like to know which kernel sized is used in ffmpeg. (FYI, I used sigma = 0.5 and sigma = 0.8.)

Now, this StackExchange question theoretically discusses the relationship between sigma, radius and kernel size. If I interpret the answers correctly, then radius = 2 * sigma. And the radius is the amount of pixels in each direction that the Gaussian filter uses. Thus, kernel_size = ceil(radius*2 + 1). For example, if sigma = 0.5, then it's a 3x3 kernel, while if sigma = 0.8, then it's a 5x5 kernel.

On the other hand, Wikipedia says: "Typically, an image processing program need only calculate a matrix with dimensions ceil(6*sigma) x ceil(6*sigma) to ensure a result sufficiently close to that obtained by the entire Gaussian distribution." Thus, again, if sigma = 0.5, then it's a 3x3 kernel, while if sigma = 0.8, then it's a 5x5 kernel.

However, I found a scientific paper titled "A Low Complexity Video Watermarking in H.264 Compressed Domain" that contradicts the previous statements. The authors claim to have used a Gaussian Filter 5x5 with sigma = 0.3 and sigma = 0.4 (in Table III and Table IV). But for those sigma's, I would expect a kernel size of 3x3?

In short, I am confused on how to deduct the kernel size used in ffmpeg, while I can only change sigma. I also do not get any wiser by reading the ffmpeg gblur source code. Is there someone who can give me clarity around this subject? Thanks in advance!

1
  • Any updates on this topic here?
    – FreshD
    Oct 2, 2020 at 15:46

1 Answer 1

1

Actually, the kernel size is a discrete kernel truncated from the continuous Normal Distribution, which is for satisfying the requirements of using convolution.

It's correct that only the sigma is requested to input. I supposed you want to know this one: About 68% of values drawn from a normal distribution are within one standard deviation σ away from the mean; about 95% of the values lie within two standard deviations, and about 99.7% are within three standard deviations. This fact is known as the 68-95-99.7 (empirical) rule or the 3-sigma rule.

So that's why the kernel size is 3x3 when sigma is 0.5. It's simply 0.5 * 3 = 1.5, and for its symmetry, the final kernel size is 3 in the case of 1D Normal Distribution. For the 2D case, it's 3x3.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .