I tried to create a Gabor Filter. We all know that this kind of filter is more complex than any other filters because it is characterized by more complex features such as having different scales and orientations. The equation of Gabor filter is:
To create such a Gabor filter with a specific scale and direction, the wikipedia gives to us a simple matlab code about that:
sigma_x = sigma;
sigma_y = sigma/gamma;
nstds = 3;
xmax = max(abs(nstds*sigma_x*cos(theta)),abs(nstds*sigma_y*sin(theta)));
xmax = ceil(max(1,xmax));
ymax = max(abs(nstds*sigma_x*sin(theta)),abs(nstds*sigma_y*cos(theta)));
ymax = ceil(max(1,ymax));
xmin = -xmax; ymin = -ymax;
[x,y] = meshgrid(xmin:xmax,ymin:ymax);
x_theta=x*cos(theta)+y*sin(theta);
y_theta=-x*sin(theta)+y*cos(theta);
gb= exp(-.5*(x_theta.^2/sigma_x^2+y_theta.^2/sigma_y^2)).*cos(2*pi/lambda*x_theta+psi);
I want to know if this code is correct. I notice that the code above didn't respond exactly to the equation of Gabor filter. For example: in the code, we have :sigma_x=sigma
and sigma_y=sigma/gamma
... and we have gb=exp(-.5*(x_theta.....))
. I didn't understand what is the 5
in the equation..
Is the matlab code written above respond correctly to the equation of the Gabor filter?? please i need your opinion and if possible to optimize the code if it is not correct.
Any help will be appreciated.