马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
%Template for Gaussian averaging
%Usage [templete]=Gaussian_templete(number,number)
%winsize-size of template(odd,integer)
%sigma-variance of Gaussian function
f=imread(Ɖ.JPG');
winsize = zeros(5,5);
sigmasize=[1,1];
f1=rgb2gray(f);
[irows,icols]=size(f1);
[wrows,wcols]=size(winsize);
[srows,scols]=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,[0 255]);
修改之后程序没有错误,可是出来的图超级小,针尖小,为什么呢?肯定是程序有问题。
如果我加入f2=zeros(irows,icols);显示的图像大小正常,但是是全部黑色。
%Template for Gaussian averaging
%Usage [templete]=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);
[irows,icols]=size(f1);
[wrows,wcols]=size(winsize);
[srows,scols]=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,[0 250]); |