A OpenCV beginner and bad math.
My job 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 the return Matrix of this function is the real part or the imaginary part of the kernel.
If I can't use this function, then how can I generate those kernel?
Using Java API, but C++ code is fine.
How to get the real and imaginary parts of a gabor kernel matrix in OpenCV
Asked Answered
You can see in gabor.cpp at line 87 that it's computing 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 to (as reported also here)
double v = scale*std::exp(ex*xr*xr + ey*yr*yr)*sin(cscale*xr + psi);
^^^
Once you have your kernel, you can use it with the function filter2d
Got it. Thank you so much! –
Kenrick
dear @Ludicrous would you please take a look at my question #49218736 –
Rory
@Ludicrous >>Dear Miki no one has answered my question yet, I appreciate if you have the time now to take a look. –
Rory
Actually the difference between cos and sin is and offset of 90 degrees or PI/2. So you can get the real and imaginary Gabor Kernels by making the PSI as 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);
© 2022 - 2024 — McMap. All rights reserved.