高斯平均算子检测物体
高斯平均算子检测物体%Template for Gaussian averaging
%Usage =Gaussian_templete(number,number)
%winsize-size of template(odd,integer)
%sigma-variance of Gaussian function
f=imread(Ɖ.JPG');
winsize = zeros(5,5);
sigmasize=;
f1=rgb2gray(f);
=size(f1);
=size(winsize);
=size(sigmasize);
% centre is half of window size
%centre=floor(winsize/2)+1
crhalf=floor(wrows/2)+1;
cchalf=floor(wcols/2)+1;
%we will normalise by the total sum
sum=0;
%so work out the coefficients and the rumming total
for j=1:wrows
for i=1:wcols
f2(j,i)=exp(-(((j-cchalf)*(j-cchalf))+((i-crhalf))*((i-crhalf)))/(2*srows*scols));%f2:template
sum=sum+f2(j,i);
end
end
%and then normlise
f2(j,i)=f2(j,i)/sum;
imshow(f2,);
修改之后程序没有错误,可是出来的图超级小,针尖小,为什么呢?肯定是程序有问题。
如果我加入f2=zeros(irows,icols);显示的图像大小正常,但是是全部黑色。
%Template for Gaussian averaging
%Usage =Gaussian_templete(number,number)
%winsize-size of template(odd,integer)
%sigma-variance of Gaussian function
f=imread('a.JPG');
winsize = zeros(5,5);
sigmasize=zeros(1,1);
f1=rgb2gray(f);
=size(f1);
=size(winsize);
=size(sigmasize);
f2=zeros(irows,icols);
% centre is half of window size
%centre=floor(winsize/2)+1
crhalf=floor(wrows/2)+1;
cchalf=floor(wcols/2)+1;
%we will normalise by the total sum
sum=0;
%so work out the coefficients and the rumming total
for j=1:wrows
for i=1:wcols
f2(j,i)=exp(-(((j-cchalf)*(j-cchalf))+((i-crhalf))*((i-crhalf)))/(2*srows*scols));%f2:template
sum=sum+f2(j,i);
end
end
%and then normlise
f2(j,i)=f2(j,i)/sum;
imshow(f2,);
页:
[1]