3

我必须在我的应用程序中使用 Gabor 过滤器,但我不知道这个 OpenCV 方法参数值。我想编码虹膜。Gabor 过滤器开始并获取特征(我想对 12 组 Gabor 参数值执行此操作)。然后我想计算一个 Hamming 异常并进行身份验证。

如果有人可以在这里写参数范围,或者如何在函数中计算它:

Imgproc.getGaborKernel(new Size(kSize[j], kSize[j]), sigma, theta, lambda, gamma);

我将不胜感激。当然,我尝试过自己分配它,但没有成功。

示例文件:

标准化虹膜

4

1 回答 1

7

您可以参考此 c++ 代码来查找图像的 Gabor Edge 检测器输出。我相信您也可以在 java 中形成类似的!使用这些值来找到你想要的内核类型。

#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <math.h>

using namespace cv;
int pos_kernel_size=21;
int pos_sigma= 5;
int pos_lm = 50;
int pos_th = 0;
int pos_gamma= 0;
int pos_psi = 90;

Mat src_f;
Mat dest;

void Process(int , void *)
{
    int kernel_size=(pos_kernel_size-1)/2;

    Size KernalSize(kernel_size,kernel_size);
    double Sigma = pos_sigma;
    double Lambda = 0.5+pos_lm/100.0;
    double Theta = pos_th*CV_PI/180;
    double psi = pos_psi*CV_PI/180;;
    double Gamma = pos_gamma;

    Mat kernel = getGaborKernel(KernalSize, Sigma, Theta, Lambda,Gamma,psi);
    filter2D(src_f, dest, CV_32F, kernel);
    imshow("Process window", dest);
    Mat Lkernel(kernel_size*20, kernel_size*20, CV_32F);
    resize(kernel, Lkernel, Lkernel.size());
    Lkernel /= 2.;
    Lkernel += 0.5;
    imshow("Kernel", Lkernel);
    Mat mag;
    pow(dest, 2.0, mag);
    imshow("Mag", mag);
}

int main(int argc, char** argv)
{
    Mat image = imread("Gabor.bmp",0);
    cv::imshow("Src", image);

    image.convertTo(src_f, CV_32F, 1.0/255, 0);

    if (!pos_kernel_size%2)
    {
        pos_kernel_size+=1;
    }
    cv::namedWindow("Process window", 1);
    cv::createTrackbar("Sigma", "Process window", &pos_sigma, pos_kernel_size, Process);
    cv::createTrackbar("Lambda", "Process window", &pos_lm, 100, Process);
    cv::createTrackbar("Theta", "Process window", &pos_th, 180, Process);
    cv::createTrackbar("Psi", "Process window", &pos_psi, 360, Process);
    cv::createTrackbar("Gamma", "Process window", &pos_gamma, 100, Process);
    Process(0,0);
    waitKey(0);
    return 0;
}
于 2014-11-17T13:57:25.177 回答