|
|
[交流]
在corel 1000图像库上提取gabor特征的gabor滤波器参数如何设置?
我的问题是newgabor滤波器中的N,freq,flag等如何设置?N是采样的矩形网格尺寸,freq是最大和最小的中心频率,flag是个选项,选1是移走gabor实部的dc值,0是不移走。partition中的stage,orientation分别代表分解层数和方向,我设置的是3,8. Corel1000中的是rgb彩色图像,对其提取gabor特征,N,index,freq,partition,flag应如何设置?我设置的N=64,freq=[0.05,.04],flag=1,但用其作检索结果不理想。相应的代码如下:
在corel 1000图像库上提取gabor特征的主程序如下:
n=1000;
feature=[];
for j=1:n
j=num2str(j);
img=imread(['C:\Program Files\MATLAB\R2013a\work\image.orig\',j,'.jpg']);
img=rgb2gray(img);
j=str2num(j);
feature(j, =newgaborfeature(img);
end
调用的newgaborfeature函数如下:
function feature=newgaborfeature(img)
if isa(img,'double')~=1
img = double(img)/255;
end
feature=[];
N=64;
freq=[0.05,0.4];
stage=3;
orientation=8;
partition=[stage,orientation];
flag=1;
for s = 1:stage
for n = 1 rientation
[Gr,Gi] = newgabor(N,[s,n],freq,partition,flag);
G=Gr+1i*Gi;
Gfilter=conv2(img,G,'same');
Gfilter=sqrt(imag(Gfilter).^2+real(Gfilter).^2);
mu=mean(mean(Gfilter));
sigma=std2(Gfilter);
feature=[feature,mu,sigma];
end
end
调用的newgabor滤波器如下:
%----------------------------------------------------------------------
% This function generate the spatial domain (空间域)of the Gabor wavelets
% which are specified by number of scales and orientations and the
% maximun and minimun center frequency(中心频率).
%
% N : the size of rectangular grid(矩形网格) to sample(采样) the gabor
% index : [s,n] specify which gabor filter is selected
% freq : [Ul,Uh] specify the maximun and minimun center frequency
% partition : [stage,orientation] specify the total number of filters
% flag : 1 -> remove the dc value of the real part of Gabor
% 0 -> not to remove
%----------------------------------------------------------------------
function [Gr,Gi] = newgabor(N,index,freq,partition,flag)
% get parameters
s = index(1);
n = index(2);
Ul = freq(1);
Uh = freq(2);
stage = partition(1);
orientation = partition(2);
% computer ratio a for generating wavelets
base = Uh/Ul;
C = zeros(1,stage);
C(1) = 1;
C(stage) = -base;
P = abs(roots(C));
a = P(1);
% computer best variance of gaussian envelope
u0 = Uh/(a^(stage-s));
Uvar = ((a-1)*u0)/((a+1)*sqrt(2*log(2)));
z = -2*log(2)*Uvar^2/u0;
Vvar = tan(pi/(2*orientation))*(u0+z)/sqrt(2*log(2)-z*z/(Uvar^2));
% generate the spetial domain of gabor wavelets
j = sqrt(-1);
if (rem(N,2) == 0)
side = N/2-0.5;
else
side = fix(N/2);
end;
x = -side:1:side;
l = length(x);
y = x';
X = ones(l,1)*x;
Y = y*ones(1,l);
t1 = cos(pi/orientation*(n-1));
t2 = sin(pi/orientation*(n-1));
XX = X*t1+Y*t2;
YY = -X*t2+Y*t1;
Xvar = 1/(2*pi*Uvar);
Yvar = 1/(2*pi*Vvar);
coef = 1/(2*pi*Xvar*Yvar);
Gr = a^(stage-s)*coef*exp(-0.5*((XX.*XX)./(Xvar^2)+(YY.*YY)./(Yvar^2))).*cos(2*pi*u0*XX);
Gi = a^(stage-s)*coef*exp(-0.5*((XX.*XX)./(Xvar^2)+(YY.*YY)./(Yvar^2))).*sin(2*pi*u0*XX);
% remove the real part mean if flag is 1
if (flag == 1)
m = sum(sum(Gr))/sum(sum(abs(Gr)));
Gr = Gr-m*abs(Gr);
end;
![在corel 1000图像库上提取gabor特征的gabor滤波器参数如何设置?]()
1.jpg
![在corel 1000图像库上提取gabor特征的gabor滤波器参数如何设置?-1]()
2.jpg
![在corel 1000图像库上提取gabor特征的gabor滤波器参数如何设置?-2]()
3.jpg
![在corel 1000图像库上提取gabor特征的gabor滤波器参数如何设置?-3]()
4.jpg |
|