- What do you have?
- Desirable Results?
using Gabor wavelet to extract texture features
3 views (last 30 days)
Show older comments
Hello,
I'm trying to build a code for extracting texture features by gabor wavelet, also after searching the net and experimenting with what i found, I do some changes but i'm not sure if it is correct, in other words, if these changes will give me what I want which is to use standard deviation and mean for a feature vector .Please note that Gabor channels are (6 orientation and 5 scales)
my images have the size of 348 by 256 and I used m = n = 40 , d1 =77 , d2 = 43 .
My question is how should I calculate d1 and d2 for downsampling and upsampling and is the code correct for extracting mean and standard deviation.
% to create Gabor Array
function gaborArray = gaborFilterBank(u,v,m,n)
% GABORFILTERBANK generates a custum Gabor filter bank.
% It creates a u by v cell array, whose elements are m by n matrices;
% each matrix being a 2-D Gabor filter.
%
%
% Inputs:
% u : No. of scales (usually set to 5)
% v : No. of orientations (usually set to 6)
% m : No. of rows in a 2-D Gabor filter (an odd integer number, usually set to 39)
% n : No. of columns in a 2-D Gabor filter (an odd integer number, usually set to 39)
%
% Output:
% gaborArray: A u by v array, element of which are m by n
% matries; each matrix being a 2-D Gabor filter
%
%
% Sample use:
%
% gaborArray = gaborFilterBank(5,6,40,40);
%
%
%
% Details can be found in:
%
% M. Haghighat, S. Zonouz, M. Abdel-Mottaleb, "CloudID: Trustworthy
% cloud-based and cross-enterprise biometric identification,"
% Expert Systems with Applications, vol. 42, no. 21, pp. 7905-7916, 2015.
%
%
%
% (C) Mohammad Haghighat, University of Miami
% haghighat@ieee.org
% PLEASE CITE THE ABOVE PAPER IF YOU USE THIS CODE.
if (nargin ~= 4) % Check correct number of arguments
error('There must be four input arguments (Number of scales and orientations and the 2-D size of the filter)!')
end
%% Create Gabor filters
% Create u*v gabor filters each being an m by n matrix
gaborArray = cell(u,v);
fmax = 0.25;
gama = sqrt(2);
eta = sqrt(2);
for i = 1:u
fu = fmax/((sqrt(2))^(i-1));
alpha = fu/gama;
beta = fu/eta;
for j = 1:v
tetav = ((j-1)/v)*pi;
gFilter = zeros(m,n);
for x = 1:m
for y = 1:n
xprime = (x-((m+1)/2))*cos(tetav)+(y-((n+1)/2))*sin(tetav);
yprime = -(x-((m+1)/2))*sin(tetav)+(y-((n+1)/2))*cos(tetav);
gFilter(x,y) = (fu^2/(pi*gama*eta))*exp(-((alpha^2)*(xprime^2)+(beta^2)*(yprime^2)))*exp(1i*2*pi*fu*xprime);
end
end
gaborArray{i,j} = gFilter;
end
end
function [featureVector,gaborResult] = gaborFeatures1(img,d1,d2)
%% Filter the image using the Gabor filter bank
% Filter input image by each Gabor filter
load 'gaborArray.mat';
[u,v] = size(gaborArray);
gaborResult = cell(u,v);
for i = 1:u
for j = 1:v
gaborResult{i,j} = imfilter(img, gaborArray{i,j});
end
end
%% Create feature vector
% Extract feature vector from input image
featureVector1 = [];
featureVector1 = [];
gaborResult = gaborResult(:);
gaborResult = gaborResult' ;
for i = 1:30
gaborResultt = cell2mat (gaborResult(i));
MeanValue = mean2 (gaborResultt);
MeanValue = abs( MeanValue);
STDValue = std2 (gaborResultt);
STDValue = abs(STDValue);
featureVector1(i) = MeanValue ;
featureVector2(i) = STDValue ;
end
featureVector = [ featureVector1 ;featureVector2 ];
featureVector = featureVector(:);
featureVector = featureVector';
end
2 Comments
KALYAN ACHARJYA
on 18 Dec 2020
If you want help, you need to make it easy to help. Please ensure the following-
Additional non-important things disturb to understand the question.
Answers (0)
See Also
Categories
Find more on Filter Banks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!