专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > 图形/图像

关于gabor filter 用于指纹细节特征点提取的matlab程序的异常有关问题

发布时间:2011-06-27 20:39:12 文章来源:www.iduyao.cn 采编人员:星星草
求助关于gabor filter 用于指纹细节特征点提取的matlab程序的错误问题
本人属于matlab的初级使用者,写毕设,要构造一个gabor filter用于提取指纹的细节特征点,按照网络上的那个三段代码,我改编了一下程序如下:
function [G,gabout]=gaborfilter(I,Sr,Ss)
if isa(I,'double')~=1
I=double(I);

end
sigma=16;
Ns=16;
Nf=16;
for p=0:Ns-1
for q=0:Ns-1
for r=-Nf/2+1:Nf/2
for s=-Nf/2+1:Nf/2
for x=-fix(Sr):fix(Sr)
for y=-fix(Ss):fix(Ss)
G(fix(Sr)+x+1,fix(Ss)+y+1)=exp(-((x-p)^2/sigma^2)*exp(2*pi*j*(x*r+y*s)/Sf);
end;
end;
end;

imgabout=conv2(I,double(image(G)),'same');
regabout=conv2(I,double(real(G)),'same');

gabout=sqrt(imgabout.*imgaabout+regabout.*regabout);
figure;
imshow(unit8(gabout),[]);

figure;
imshow(unit8(real(G),[]);
但是在运行的过程中一直出现如下错误,即使我把从网上档下来的输入matlab中也会出现

??? function gaborfilter(I, Sr,Ss);
|
Error: Function definitions are not permitted at the prompt or in scripts.

查找一些资料后发现有人给出建议说:MATLAB不允许在脚本文件中定义函数,
由于在M-files的前几行并没有定义如同function functionName(value)的函数声明,因此造成我所写的M-files被MATLAB认为是脚本文件,解决方法是在M文件前面加了一个不带输入变量的函数定义,ERROR就不再产生了。我修改了好几次,但是一直出现一些问题,希望各位大虾给我一些建议,因为非常初级,所以不明白什么意思,另外能否帮忙看看程序是否有问题,本人很急,快要交论文了,程序还没结果
我现在最基本的要求就是根据表达式
G(x,y)=exp{-[(x-p)2+(y-q)2/sigma2}exp[2pij(xr+ys)/Nf],Nf=sigma=16=Ns是给定的,画出图形然后再继续往下分析,但是目前连个图都没出来,
望各位大虾帮帮忙,不胜感激 ,弱弱的说一下,其实我对这几个参数的设定的意思还没有理解,完全是依葫芦画瓢的,现在我贴出原来的程序如下
%%%%%%%VERSION 1

%The Gabor filter is basically a Gaussian (with variances sx and sy along x and y-axes respectively)
%modulated by a complex sinusoid (with centre frequencies U and V along x and y-axes respectively) 
%described by the following equation
%%
% 1 -1 x ^ y ^
%%% G(x,y) = ---------- * exp ([----{(----) 2+(----) 2}+2*pi*i*(Ux+Vy)])
% 2*pi*sx*sy 2 sx sy

%% Describtion :

%% I : Input image
%% Sx & Sy : Variances along x and y-axes respectively
%% U & V : Centre frequencies along x and y-axes respectively

%% G : The output filter as described above
%% gabout : The output filtered image

%% Author : Ahmad poursaberi e-mail : a.poursaberi@ece.ut.ac.ir
%% Faulty of Engineering, Electrical&Computer Department,Tehran
%% University,Iran,June 2004

function [G,gabout] = gaborfilter(I,Sx,Sy,U,V);

if isa(I,'double')~=1 
  I = double(I);
end

for x = -fix(Sx):fix(Sx)
  for y = -fix(Sy):fix(Sy)
  G(fix(Sx)+x+1,fix(Sy)+y+1) = (1/(2*pi*Sx*Sy))*exp(-.5*((x/Sx)^2+(y/Sy)^2)+2*pi*i*(U*x+V*y));
  end
end

Imgabout = conv2(I,double(imag(G)),'same');
Regabout = conv2(I,double(real(G)),'same');

gabout = uint8(sqrt(Imgabout.*Imgabout + Regabout.*Regabout));

麻烦哪位高手帮忙看看程序有没问题,还有怎么出图,谢谢,我的msn:graciejiang8@hotmail.com欢迎加我

------解决方案--------------------
for p=0:Ns-1 
for q=0:Ns-1 
for r=-Nf/2+1:Nf/2 
for s=-Nf/2+1:Nf/2 
for x=-fix(Sr):fix(Sr) 
for y=-fix(Ss):fix(Ss) 
G(fix(Sr)+x+1,fix(Ss)+y+1)=exp(-((x-p)^2/sigma^2)*exp(2*pi*j*(x*r+y*s)/Sf); 
end; 
end; 
end; 

end;%少了很多 end;
end; 
end;

并且上面只等价于

p=Ns-1 
q=Ns-1 
r=Nf/2 
s=Nf/2 
for x=-fix(Sr):fix(Sr) 
for y=-fix(Ss):fix(Ss) 
G(fix(Sr)+x+1,fix(Ss)+y+1)=exp(-((x-p)^2/sigma^2)*exp(2*pi*j*(x*r+y*s)/Sf); 
end; 
end;
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: