OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Fri, 03 Aug 2012 02:59:22 -0500How to intuitively interpret Gabor lambda param?http://answers.opencv.org/question/1066/how-to-intuitively-interpret-gabor-lambda-param/I am playing with the newly added Gabor filters. I know some basics about them, and how they are used for recognition tasks. But I have troubles understanding in an intuitive way (not by writing complicated math formulas) what is the meaning of the lambda parameter.
Here is the formula, from Wiki:
![image description](/upfiles/13439015264160707.png)
And here are some pictures, where I varied lambda:
**`lambda = CV_PI`**
![image description](/upfiles/1343901570528050.png)
**`lambda = CV_PI/2`**
![image description](/upfiles/13439016092073158.png)
**`lambda = CV_PI/4`**
![image description](/upfiles/13439016168623399.png)
The other parameters are as follows:
gaborKernel = getGaborKernel( cv::Size(15, 15) , 3, -CV_PI/4, lambda, 1, CV_PI, CV_32F );Thu, 02 Aug 2012 05:03:08 -0500http://answers.opencv.org/question/1066/how-to-intuitively-interpret-gabor-lambda-param/Answer by sammy for <p>I am playing with the newly added Gabor filters. I know some basics about them, and how they are used for recognition tasks. But I have troubles understanding in an intuitive way (not by writing complicated math formulas) what is the meaning of the lambda parameter. </p>
<p>Here is the formula, from Wiki: </p>
<p><img alt="image description" src="/upfiles/13439015264160707.png"></p>
<p>And here are some pictures, where I varied lambda:</p>
<p><strong><code>lambda = CV_PI</code></strong></p>
<p><img alt="image description" src="/upfiles/1343901570528050.png"></p>
<p><strong><code>lambda = CV_PI/2</code></strong></p>
<p><img alt="image description" src="/upfiles/13439016092073158.png"></p>
<p><strong><code>lambda = CV_PI/4</code></strong></p>
<p><img alt="image description" src="/upfiles/13439016168623399.png"></p>
<p>The other parameters are as follows:</p>
<pre><code>gaborKernel = getGaborKernel( cv::Size(15, 15) , 3, -CV_PI/4, lambda, 1, CV_PI, CV_32F );
</code></pre>
http://answers.opencv.org/question/1066/how-to-intuitively-interpret-gabor-lambda-param/?answer=1105#post-id-1105I was able to decode the strange behavior of the Gabor functions by keeping the other parameters constant in a more favorable position; This way, as seen from the graphic, the lambda parameter controls the frequency of the sinusoidal function that composes the kernel.
Conclusion: it controls the harmonic's frequency.
**Edit**
[This gorgeous answer](http://math.stackexchange.com/a/179564/37066) from two math scholars shed some light on the strange pattern seen in the second graph. It's all about small details... here, numerical stability. Setting lambda to bigger values ( > 2) solves the issue. The comments are as useful as the post.
![image description](/upfiles/13439803886996293.png)
**Bonus:** The other parameters explained for non-math students:
**psi** - shift, in radians of the sinusoidal from center.
- 0 means that the max value in in center (symetrical, max positive)
- CV_PI/2 means that the max and min crescents are at the sides of the center (antisymetrical) - as in the above example
- CV_PI - min (negative value) in center (symetrical, max negative)
**gamma** - how elongated the filter is in the lateral direction. Seem to be the complement for the gaussian sigma, in the lateral direction.
Note that low values mean elongated filters. 1 seem to a good default value.
**sigma** the good old sigma from the gaussian distribution. Controls the spread (radius)of the kernel
**theta** The rotation angle of the kernel. This way, you can select vertical stripes, horizontal stripes, or any other angle. It is the parameter of choice if you want to select, by example, edges at a given angle in an image. If you look for edges at 45 degrees, your gabor kernel will have to have a theta of `pi/4`
Fri, 03 Aug 2012 02:59:22 -0500http://answers.opencv.org/question/1066/how-to-intuitively-interpret-gabor-lambda-param/?answer=1105#post-id-1105