GaborFilter

PURPOSE ^

GaborFilter - generate Gabor filter at fixed scale and orientation.

SYNOPSIS ^

function [G, symbol] = GaborFilter(scale, orient)

DESCRIPTION ^

 GaborFilter - generate Gabor filter at fixed scale and orientation.

 "G" is the Gabor pair
 "symbol" is the bar for display

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [G, symbol] = GaborFilter(scale, orient)
0002 % GaborFilter - generate Gabor filter at fixed scale and orientation.
0003 %
0004 % "G" is the Gabor pair
0005 % "symbol" is the bar for display
0006 expand = 12; h = floor(scale * expand+.5);  
0007 alpha = (pi * orient)/180;  % alpha is orientation
0008 Gauss = zeros(h+h+1);  % Gaussian function
0009 Gcos = zeros(h+h+1); Gsin = zeros(h+h+1); % Gabor cos and sine pair
0010 symbol = zeros(h+h+1); 
0011 for x0 = -h : h
0012     for y0 = -h : h
0013         if (x0^2+y0^2>h^2) 
0014             inCircle = 0;  % zeros for pixels outside the circle
0015         else
0016             inCircle = 1; 
0017         end
0018         x = (x0 * cos(alpha) + y0 * sin(alpha))/scale; 
0019         y = (y0 * cos(alpha) - x0 * sin(alpha))/scale;
0020         g = exp(-(4*x^2+y^2)/100)/50/pi/scale^2; 
0021         Gauss(h+x0+1,h+y0+1) = g*inCircle; 
0022         Gcos(h+x0+1, h+y0+1) = g*cos(x)*inCircle;
0023         Gsin(h+x0+1, h+y0+1) = g*sin(x)*inCircle;
0024         symbol(h+x0+1, h+y0+1) = (abs(x)<3.4)*inCircle; % make a bar
0025     end
0026 end
0027 s = sum(Gauss(:)); sc = sum(Gcos(:)); r = sc/s; 
0028 Gcos = Gcos - Gauss*r;   % mean is 0 by substracting DC component
0029 Scos = sqrt(sum(sum(Gcos.^2))); Ssin = sqrt(sum(sum(Gsin.^2)));
0030 Gcos = Gcos/Scos; Gsin = Gsin/Ssin; % l_2 norm is 1.
0031 G = Gcos + sqrt(-1)*Gsin;  % sine and cosine pair
0032 
0033 
0034 
0035 
0036 
0037 
0038

Generated on Sat 23-Jan-2010 22:26:10 by m2html © 2005