Gabor kernel parameters in OpenCV

丶灬走出姿态 提交于 2020-01-04 03:56:08

问题


I must use Gabor filter in my application, but I have no clue about this OpenCV methods parameters values. I want to encoding an iris. Start of Gabor filter and get features (I want to do this for 12 sets of Gabor parameters values). Then I want to count a Hamming dystans and do authentication.

If someone could write here params ranges, or way how to calculate it in function:

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

I'll be very grateful. Of course I have tried to assign it myself, but without success.

Example file:


回答1:


You can refer this c++ code for finding Gabor Edge detector output for your image.I'm sure that you can form similar in java too! Play around with these values to find your desired kernel Type.

#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;
}


来源:https://stackoverflow.com/questions/26948110/gabor-kernel-parameters-in-opencv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!