Sigma computation in getGaussianKernel

Hello there!

I was reading the getGaussianKernel documentation it mentiones the following about how sigma is computed when given a non positive value:

sigma: Gaussian standard deviation. If it is non-positive, it is computed from ksize as sigma = 0.3*((ksize-1)*0.5 - 1) + 0.8

I was wondering where such computation is derived from.

Thanks in advance!

IIRC that’s figuring about 3 sigma in the kernel size, with some fiddling for rounding reasons.

a gaussian distribution has 99.7% of its probability mass within 3 sigma. that’s good enough for 8 bits of precision.

plug some values in, consider the result.

1 Like

Yes, thanks, that makes sense. I was not sure if the fiddling part had a different reason behind it or not.

Thanks a lot!

Posted something else but realised the calculation was for sigma, not for ksize. Thanks again!