【问题标题】:How to get the real and imaginary parts of a gabor kernel matrix in OpenCV如何在 OpenCV 中获取 gabor 核矩阵的实部和虚部
【发布时间】:2016-02-20 06:34:28
【问题描述】:

OpenCV 初学者和糟糕的数学。 我的工作是将 Gabor 过滤器应用于标准化图像。而且我只知道OpenCV有一个getGaborKernel函数,我想知道这个函数的返回矩阵是内核的实部还是虚部。 如果我不能使用这个功能,那我该如何生成那些内核呢? 使用 Java API,但 C++ 代码很好。

【问题讨论】:

    标签: opencv image-processing iris-recognition


    【解决方案1】:

    您可以在第 87 行的 gabor.cpp 中看到它正在计算 real 部分(根据 wikipedia)。

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

    您可以得到将这一行修改为的虚部(也报告了here

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

    一旦你有了你的内核,你就可以将它与函数filter2d一起使用

    【讨论】:

    • 知道了。非常感谢!
    • 亲爱的@Miki 请你看看我的问题stackoverflow.com/questions/49218236/…
    • @Miki >>亲爱的Miki还没有人回答我的问题,如果你现在有时间看一下,我很感激。
    【解决方案2】:

    实际上 cos 和 sin 之间的差异是偏移 90 度或 PI/2。 因此,您可以通过将 PSI 设置为 0 表示实数和 PI/2 表示虚数来获得实数和虚数的 Gabor Kernels。

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

    【讨论】:

      猜你喜欢
      • 2014-01-15
      • 1970-01-01
      • 1970-01-01
      • 2014-04-14
      • 1970-01-01
      • 1970-01-01
      • 2019-05-14
      • 2015-01-12
      • 2012-10-17
      相关资源
      最近更新 更多