You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.4 KiB

function gb=gabor2D(sigma,orient,wavel,phase,aspect,pxsize,x0,y0)
%function gb=gabor2D(sigma,orient,wavel,phase,aspect,pxsize,x0,y0)
% This function produces a numerical approximation to 2D Gabor function.
% Parameters:
% sigma = standard deviation of Gaussian envelope, this in-turn controls the
% size of the result (pixels)
% orient = orientation of the Gabor clockwise from the vertical (degrees)
% wavel = the wavelength of the sin wave (pixels)
% phase = the phase of the sin wave (degrees)
% aspect = aspect ratio of Gaussian envelope (0 = no "width" to envelope,
% 1 = circular symmetric envelope)
% pxsize = the size of the filter (optional). If not specified, size is 5*sigma.
% x0,y0 = location of the centre of the gaussian.
% Optional, if not specified gaussian is centred in the middle of image.
if nargin<6 || isempty(pxsize), pxsize=odd(5*sigma); end
if nargin<7 || isempty(x0), x0=0; end
if nargin<8 || isempty(y0), y0=0; end
%define grid of x,y coodinates at which to define function
[x y]=meshgrid(-pxrange:pxrange,-pxrange:pxrange);
% Rotation
gb=exp(-0.5.*( ((x_theta.^2)/(sigma^2)) ...
+ ((y_theta.^2)/((aspect*sigma)^2)) )) ...
.* (cos(freq*y_theta+phase) - cos(phase).*exp(-0.25.*((sigma*freq).^2)));