如何在OpenCV中获取gabor内核矩阵的实部和虚部 [英] How to get the real and imaginary parts of a gabor kernel matrix in OpenCV
问题描述
OpenCV初学者和糟糕的数学。
我的工作是将Gabor滤镜应用于标准化图像。我只知道OpenCV有一个 getGaborKernel
函数,我想知道这个函数的返回矩阵是内核的实部或虚部。
如果我不能使用这个函数,那么我该如何生成这些内核?
使用Java API,但C ++代码没问题。
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.
推荐答案
你可以在 gabor.cpp 第87行它正在计算真实 part(根据维基百科)。
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);
^^^
获得内核后,可以将其与函数<一起使用a href =http://docs.opencv.org/2.4/modules/imgproc/doc/filtering.html?#filter2d =nofollow> filter2d
Once you have your kernel, you can use it with the function filter2d
这篇关于如何在OpenCV中获取gabor内核矩阵的实部和虚部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!