我准备在C#中实现高斯滤波器,在准备过程中,我正在阅读有关这方面的文献。然而,我有不同的消息来源。
有一本书(日本文本:内村实用图像处理简介)规定计算模板的等式为
w(u,v)= (1/2*pi*sigma^2) exp(-(x^2+v^2)/(2*sigma^2)).
SIZE = 3*sigma
.
w(u,v)= (1/SUM)* exp(-(x^2+v^2)/(2*sigma^2))
哪里
SUM
是所有指数值的总和。下面是他们提供的伪代码-我认为它接近MATLAB。
function template=gaussian_template(winsize,sigma)
%Template for Gaussian averaging
%Usage:[template]=gaussian_template(number, number)
%Parameters: winsize-size of template (odd, integer)
% sigma-variance of Gaussian function
%Author: Mark S. Nixon
%centre is half of window size
centre=floor(winsize/2)+1;
%we'll normalise by the total sum
sum=0;
%so work out the coefficients and the running total
for i=1:winsize
for j=1:winsize
template(j,i)=exp(-(((j-centre)*(j-centre))+((i-centre)*(i-centre)))/(2*sigma*sigma))
sum=sum+template(j,i);
end
end
%and then normalise
template=template/sum;
我的问题是,你们中有人使用过高斯滤波实现吗?这个等式正确吗?你知道为什么这本书给出了一个更简单的实现吗?