3
$\begingroup$

I have troubles understanding in an intuitive way (not by writing complicated math formulas) what is the meaning of the lambda parameter in the Gabor functions. (I have basic math understanding, grad level, but this look a bit too much for me)

Is it a parameter that controls the sinusoidal part of the function? Or the gaussian part of it? And why those funny effects at $\pi/2$ ?

Here is the formula, from Wiki (real part of the equation): $ g(x, y; \lambda, \theta, \psi, \sigma, \gamma) = \exp \left(- \frac{x'^2 + \gamma^2 y'^2}{2 \sigma^2} \right) \cos \left( 2\pi \frac{x'}{\lambda} + \psi \right)$

Were

$x' = x \cos \theta + y \sin \theta$

and

$y' = -x \sin \theta + y \cos \theta$

And here are some pictures, where I varied lambda:

$\lambda = \pi$

enter image description here

$\lambda = \pi/2$

enter image description here

$\lambda = \pi/4$

enter image description here

The other parameters are as follows: $ \sigma = 3 \\ \theta = -\pi/4 \\ \gamma = 1 \\ \psi = \pi $

Edit The code I use is below (taken from OpenCV)

cv::Mat cv::getGaborKernel( Size ksize, double sigma, double theta,                             double lambd, double gamma, double psi, int ktype ) {     double sigma_x = sigma;     double sigma_y = sigma/gamma;     int nstds = 3;     int xmin, xmax, ymin, ymax;     double c = cos(theta), s = sin(theta);      if( ksize.width > 0 )         xmax = ksize.width/2;     else         xmax = cvRound(std::max(fabs(nstds*sigma_x*c), fabs(nstds*sigma_y*s)));      if( ksize.height > 0 )         ymax = ksize.height/2;     else         ymax = cvRound(std::max(fabs(nstds*sigma_x*s), fabs(nstds*sigma_y*c)));      xmin = -xmax;     ymin = -ymax;      CV_Assert( ktype == CV_32F || ktype == CV_64F );      Mat kernel(ymax - ymin + 1, xmax - xmin + 1, ktype);     double scale = 1/(2*CV_PI*sigma_x*sigma_y);     double ex = -0.5/(sigma_x*sigma_x);     double ey = -0.5/(sigma_y*sigma_y);     double cscale = CV_PI*2/lambd; // Here is the interesting part. What happens here?      for( int y = ymin; y <= ymax; y++ )         for( int x = xmin; x <= xmax; x++ )         {             double xr = x*c + y*s;             double yr = -x*s + y*c;              double v = scale*exp(ex*xr*xr + ey*yr*yr)*cos(cscale*xr + psi);             if( ktype == CV_32F )                 kernel.at(ymax - y, xmax - x) = (float)v;             else                 kernel.at(ymax - y, xmax - x) = v;         }      return kernel; } 
  • 0
    Try this link, here they briefly explained about what is gabor filter and its parameters http://www.cs.rug.nl/~imaging/simplecell.html2014-04-05

1 Answers 1

1

The term $\cos \left( 2\pi \frac{x'}{\lambda} + \psi \right)$ describes a wave of wavelength $\lambda$, because adding $\lambda$ to $x'$ does not change the value of this function. if you had $x$ instead of $x'$ there, the waves would be "flowing left to right" on the picture, more precisely each wavefront would be vertical. The transformation from $x,y$ to $x',y'$ rotates the picture by $\pi/4$, so we see wavefronts (colored stripes) along the NW-SE line.

The other factor $\exp \left(- \frac{x'^2 + \gamma^2 y'^2}{2 \sigma^2} \right)$ decreases the amplitude away from the origin. This is why the stripes become less distinct toward the edges of each picture.

The above explains everything I see on the 1st and 3rd graph. It does not explain the 2nd graph, where we see another oscillating pattern in the $y'$ direction. I think the 2nd graph shows a different function.

  • 0
    Thanks guys! Great info! I'd love to upvote both of you, but so far only Leonid takes the votes :). The axis labels are a good reminder indeed2012-08-06