資源簡介
Gabor小波提取圖像紋理特征,matlab語言編寫,簡單實用,運行通過

代碼片段和文件信息
%?%function?Gabor_wavelet(mn)
%?%?m指定濾波器的尺度
%?%?n指定濾波器的方向
%?
%?width=6;
%?[xy]=meshgrid(-width:width-width:width);
%?
%?M=5;???%?M表示總共有5個尺度
%?N=6;???%?N表示總共有6個方向
%?
%?for?m=5:M
%?????for?n=6:N
%?Uh=0.4;
%?Ul=0.05;
%?%?a=(Uh/Ul).^(-1/(M-1));
%?sigma_x=(a+1)*sqrt(2*log(2))/(2*pi*a.^m*(a-1)*Ul);
%?sigma_y=1/(2*pi*tan(pi/2*N)*sqrt(Uh.^2/2*log(2)-(1/2*pi*sigma_x).^2));
%?%?W=a.^m*Ul;
%?
%?%?Uh=pi/0.2;
%?%?Ul=Uh/8;
%?a=(Uh/Ul).^(-1/(M-1));
%?%?sigma_u=(a-1)*Uh/((a+1)*sqrt(2*log(2)));
%?%?sigma_v=tan(pi/(2*N))*(Uh-2*log(2)*sigma_u.^2/Uh)*(2*log(2)-(2*log(2)).^2*sigma_u.^2/Uh.^2).^(-1/2);
%?
%?sigma_u=1/(2*pi*sigma_x);
%?sigma_v=1/(2*pi*sigma_y);
%?W=Uh;
%?
%?theta=n*pi/N;?%?指定濾波器的方向
%?
%?xx=a.^(-m)*(x*cos(theta)+y*sin(theta));
%?yy=a.^(-m)*(-x*sin(theta)+y*cos(theta));
%?
%?%gabor=a.^(-m)/(2*pi*sigma_x*sigma_y)*exp(-(xx.^2/sigma_x.^2+yy.^2/sigma_y.^2)/2)*exp(2*pi*sqrt(-1)*W*xx);
%??gabor=a.^(-m)*exp((-1/2)*((xx-W).^2/sigma_u.^2+yy.^2/sigma_v.^2));
%?
%?figure
%?imshow(real(gabor)[]);
%?end
%?end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%————————————————?VERSION?1?————————————————
%%ANOTHER?DESCRIBTION?OF?GABOR?FILTER
%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?????x‘?^?????y‘??^?????????????
%%%?G(xythetaf)?=??exp?([----{(----)?2+(----)?2}])*cos(2*pi*f*x‘);
%?????????????????????????????2????sx‘???????sy‘
%%%?x‘?=?x*cos(theta)+y*sin(theta);
%%%?y‘?=?y*cos(theta)-x*sin(theta);
%%?Describtion?:
%%?I?:?Input?image
%%?Sx?&?Sy?:?Variances?along?x?and?y-axes?respectively
%%?f?:?The?frequency?of?the?sinusoidal?function
%%?theta?:?The?orientation?of?Gabor?filter
%%?G?:?The?output?filter?as?described?above
%%?gabout?:?The?output?filtered?image
%%?Author:?Perky
%?????????E-mail:?mshgirl1981@sina.com
%?????????Texture?Lab?????Ocean?University?of?China
%?????????2006.8.9?
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function?[Ggabout]?=?Gabor_wavelet1(Isigmafthetawidth)
%?這個Gabor濾波器與正弦函數的頻率有關,也與方向有關
%?I=rgb2gray(imread(‘image.bmp‘));
%?sigma=pi/2;
%?theta=2*pi/3;
%?f=pi/1.4;
%?width=5;
Sx=width;
Sy=width;
if?isa(I‘double‘)~=1?
????I?=?double(I);
end
for?x?=?-fix(Sx):fix(Sx)
????for?y?=?-fix(Sy):fix(Sy)
????????xPrime?=?x?*?cos(theta)?+?y?*?sin(theta);
????????yPrime?=?y?*?cos(theta)?-?x?*?sin(theta);
????????G(fix(Sx)+x+1fix(Sy)+y+1)?=?exp(-.5*(xPrime^2+yPrime^2)/sigma.^2)*cos(2*pi*f*xPrime);
????end
end
Imgabout?=?conv2(Idouble(imag(G))‘same‘);
Regabout?=?conv2(Idouble(real(G))‘same‘);
gabout?=?sqrt(Imgabout.*Imgabout?+?Regabout.*Regabout);
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2008-04-11?14:59??Gaborwavorforedge\
?????目錄???????????0??2006-11-29?21:09??Gaborwavorforedge\Gabor\
?????文件????????3086??2006-11-29?21:09??Gaborwavorforedge\Gabor\Gabor_wavelet1.m
?????文件?????????542??2006-11-29?21:08??Gaborwavorforedge\Gabor\getf_Gabor.m
?????文件????????1223??2008-01-29?17:37??Gaborwavorforedge\說明.txt
- 上一篇:yw5bth.m
- 下一篇:FDTD(時域有限差分法)算法的Matlab源程序
評論
共有 條評論