Closed ozgaga6688 closed 2 years ago
A true Gaussian blur is defined on an infinite domain and has only one parameter which is sigma.
To remain feasible in practice, we clamp a portion of the Gaussian with a discrete kernel, whose radius is often automatically computed from the desired sigma, so that it covers 95% to 99% of the Gaussian range (cf. Gaussian empirical rule).
Sometimes this radius is exposed to the user, such that one can control the complexity of the Gaussian convolution in one's program, however the FastGaussianBlur approximates a Gaussian with several passes of box blur.
We hence have to compute internally the box blur radius of each pass from the desired sigma to get the closest possible result to the true convolution (cf. Peter Kovesi's article). This is done with the sigma_to_box_radius
function.
That is why the kernel size is not exposed to the user with this method.
Why do you specifically need the kernel size ?
because I used OpenCV's cvSmooth function before, and can set kernel size and sigma in cvSmooth. Bur now i need to implement gaussian blur in ARM, so i want to use this method gets the same result with cvSmooth but faster. Oh, in Opencv, i set sigma = (kSize-1)/4
OpenCV lets you specify a kernel size, sigma_x and sigma_y, however if you specify a kernel size of (0,0), it will be automatically deduced from the sigma parameters as said in the Gaussian blur documentation:
ksize Gaussian kernel size. ksize.width and ksize.height can differ but they both must be positive and odd. Or, they can be zero's and then they are computed from sigma.
So I suggest you to find your sigma parameters in OpenCV without specifying the kernel size, so you can reproduce a similar result using fast blur approximations, for which the sigma is the only parameter.
The fast Gaussian blur methods (recursive box blur or recursive IIR filters) are designed to resolve medium or high values of sigma super fast, and are not well suited for small sigmas, as a simple separable Gaussian blur implementation is faster and of better quality. For sigma = 1 you should consider a dedicated separable Gaussian blur implementation !
The traditional gaussian blur has a gaussian kernel,and this kernel has two important parameters : kernel‘s size and sigma. but i can't see the kernel's size in your method.