Recursive gaussian filter vs traditional gaussian filter

6 次查看(过去 30 天)
Some papers say Recursive gaussian filter is much faster than traditional gaussian filter. Traditional gaussian filter accepts a 2D MxN matrix as kernel. While, Recursive gaussian filter accepts a 1D float sigma as kernel.
If I have a 2D kernel for traditional guassian filter before. I want to use Recursive Gaussian now. How to calculate the corresponding 1D float sigma to get a closest result to traditional filter?
e.g: int kernel[25] = { 1, 4, 7, 4, 1, 4, 16, 26, 16, 4, 7, 26, 41, 26, 7, 4, 16, 26, 16, 4, 1, 4, 7, 4, 1 }; How to calculate sigma for this 2D kernel?
Regards
zlf

回答(2 个)

Junaid
Junaid 2011-12-2
As I understand your code and question. you have kernel variable.
Kernel =[1, 4, 7, 4, 1, 4, 16, 26, 16, 4, 7, 26, 41, 26, 7, 4, 16, 26, 16, 4, 1, 4, 7, 4, 1];
and you want to compute the gaussian for this. let say G.
G = fspecial('gaussian', size(Kernel),5);
where 5 is initiall value of sigma, you tune it as you like. You can plot your G as well. Like this
plot([1:length(G)], G)

Image Analyst
Image Analyst 2011-12-2
Sounds like maybe you're mixing up the method of separable kernels and recursive filtering.
Because the convolution of two Gaussians is another Gaussian, filtering an image with a Gaussian and then doing it again is the same as filtering once with a larger Gaussian. That would be recursive filtering. (By the way if you convolve anything (other than a delta function or comb function) with itself enough times (more than about 6) it is essentially the same as a Gaussian for all intents and purposes.
Now you can get a 2D Gaussian kernel by convolving once in the vertical direction with a 1D Gaussian filter, and then filter that result by another 1D Gaussian in the horizontal direction. That's the method of separable kernels.

类别

Help CenterFile Exchange 中查找有关 Regression 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by