开发者

Programatically fill a nxn matrix with a gaussian filter in C++

I need to fill an nXn matrix with a Gaussian filter programatically. I've been trying to work开发者_C百科 this out for a graphics project, but i'm a little stuck.

To clarify, an example 3x3 Gaussian filter matrix would be:

[1, 2, 1]

[2, 4, 2] / 16.0

[1, 2, 1]


You just need a formula for a 2d gauss kernel and fill in your x and y values.

e.g. symmetric gauss kernel:

 double w = exp(-(fx*fx + fy*fy) / (2.0 * sigma * sigma)) / (2.0 * M_PI * sigma * sigma);

For an explanation with nice graphs see:

http://www.librow.com/articles/article-9

especially: 3. 2D case

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜