Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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)$$


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


$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;
        xmax = cvRound(std::max(fabs(nstds*sigma_x*c), fabs(nstds*sigma_y*s)));

    if( ksize.height > 0 )
        ymax = ksize.height/2;
        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 )
      <float>(ymax - y, xmax - x) = (float)v;
      <double>(ymax - y, xmax - x) = v;

    return kernel;
share|cite|improve this question
The arguments of $g$ are $x,y,\dots$ but the formula you gave has $x',y'$. What is the relation between $x,y$ and $x',y'$? – user31373 Aug 6 '12 at 15:44
@LeonidKovalev added them. I have forgotten an important detail :) – vasile Aug 6 '12 at 16:26
hello i am also in same problem can i get small help from your side about gabor filter bank ? If you can then can i get your personal email details :) Thanks, Satish – relstudiosnx Dec 16 '12 at 19:21
Try this link, here they briefly explained about what is gabor filter and its parameters – user140563 Apr 5 '14 at 7:02
up vote 1 down vote accepted

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.

share|cite|improve this answer
Thanks! I am still trying to understand the second graph. Which is created with the same function - I generated it myself - with the parameters from above. It may be something similar to diffraction patterns - alternate sine functions accumulate or subtract at different points in space – vasile Aug 6 '12 at 17:35
@vasile Maybe it's a numerical artifact (unlikely) or you made a typo in your code. Can you post the code? – user31373 Aug 6 '12 at 17:37
@LeonidKovalev: in this applet they specify : "The wavelength is given in pixels. Valid values are real numbers between 2 and 256". This could explain the nature of the artifact! – Raymond Manzoni Aug 6 '12 at 17:45
@vasile: In details: this is merely $2\pi/\lambda$ i.e. an optimization. I think that the real problem is that $x$ and $y$ are integers (and incremented by $1$). When $\lambda <2$ you'll get strong variations of values inside the $\cos$ and you'll get visual artifacts because of this. I think that $\lambda$ should be larger than $2$ or the sampling smaller or the whole thing should be rescaled (if you insist on using these too small $\lambda$)... – Raymond Manzoni Aug 6 '12 at 18:14
@RaymondManzoni Thanks for providing the context. Then the 1st and 3rd graphs must also be interference patterns, which happen to resemble what should have actually happened, but on a different scale. A note to vasile: label the axes – user31373 Aug 6 '12 at 18:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.