|
|
[交流]
在corel 1000圖像庫上提取gabor特征的gabor濾波器參數(shù)如何設(shè)置?
我的問題是newgabor濾波器中的N,freq,flag等如何設(shè)置?N是采樣的矩形網(wǎng)格尺寸,freq是最大和最小的中心頻率,flag是個選項,選1是移走gabor實部的dc值,0是不移走。partition中的stage,orientation分別代表分解層數(shù)和方向,我設(shè)置的是3,8. Corel1000中的是rgb彩色圖像,對其提取gabor特征,N,index,freq,partition,flag應(yīng)如何設(shè)置?我設(shè)置的N=64,freq=[0.05,.04],flag=1,但用其作檢索結(jié)果不理想。相應(yīng)的代碼如下:
在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
調(diào)用的newgaborfeature函數(shù)如下:
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
調(diào)用的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(矩形網(wǎng)格) 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濾波器參數(shù)如何設(shè)置?]()
1.jpg
![在corel 1000圖像庫上提取gabor特征的gabor濾波器參數(shù)如何設(shè)置?-1]()
2.jpg
![在corel 1000圖像庫上提取gabor特征的gabor濾波器參數(shù)如何設(shè)置?-2]()
3.jpg
![在corel 1000圖像庫上提取gabor特征的gabor濾波器參數(shù)如何設(shè)置?-3]()
4.jpg |
|