Calculate the Gaussian filter's sigma using the kernel's size

后端 未结 1 1665
误落风尘
误落风尘 2021-01-18 01:05

I find on the OpenCV documentation for cvSmooth that sigma can be calculated from the kernel size as follows: sigma = 0.3(n/2 - 1) + 0.8

I would like to know the the

相关标签:
1条回答
  • 2021-01-18 01:49

    Using such a value for sigma, the ratio between the value at the centre of the kernel and on the edge of the kernel, found for y=0 and x=n/2-1, is:

    g_edge / g_center = exp(-(x²+y²)/(2σ²))
                      = exp(-(n/2-1)²/(2*(0.3(n/2-1)+0.8)²))
    

    The limit of this value as n increases is:

    exp(-1/(2*0.3²)) = 0.00386592
    

    Note that 1/256 is 0.00390625. Images are often encoded in 256-value ranges. The choice of 0.3 ensures that the kernel considers all pixels that may significantly influence the resulting value.

    I am afraid I do not have an explanation for the 0.8 part, but I imagine it is here to ensure reasonable values when n is small.

    0 讨论(0)
提交回复
热议问题