How to get the real and imaginary parts of the gabor core matrix in OpenCV

OpenCV newbie and bad math. My task is to apply the Gabor filter to a normalized image. And I only know that OpenCV has a getGaborKernel function, and I want to know that the return matrix of this function is the real part or imaginary part of the kernel. If I cannot use this function, then how can I generate this kernel? Using the Java API, but C ++ code is fine.

0
image-processing opencv iris-recognition
source share
2 answers

You can see in gabor.cpp on line 87 that it computes the real part (according to wikipedia ).

 double v = scale*std::exp(ex*xr*xr + ey*yr*yr)*cos(cscale*xr + psi); 

You can get the imaginary part modifying this line (as reported also here )

 double v = scale*std::exp(ex*xr*xr + ey*yr*yr)*sin(cscale*xr + psi); ^^^ 

Once you have a kernel, you can use it with the filter2d function

+1
source share

In fact, the difference between cos and sin is equal and is shifted 90 degrees or PI / 2. Thus, you can get the real and imaginary Gabor kernels by making the PSI equal to 0 for real and PI / 2 for imaginary.

Mat kernelReal = getGaborKernel (ksize, sigma, theta, lambda, gamma, 0, 0, CV_32F); Mat kernelImag = getGaborKernel (ksize, sigma, theta, lambda, gamma, 0, PI / 2, CV_32F);

+1
source share

All Articles