Ask Your Question
3

Gabor kernel parameters in OpenCV

asked 2014-11-16 02:57:57 -0600

Araneo gravatar image

updated 2014-11-16 04:51:09 -0600

berak gravatar image

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:

normalized iris

edit retag flag offensive close merge delete

Comments

It is marked as 1 answer, but I cannot see any, is this a bug or what?

thdrksdfthmn gravatar imagethdrksdfthmn ( 2014-11-17 09:49:35 -0600 )edit

Yes, forum is bugged. For example I must write a comment to see yours

Araneo gravatar imageAraneo ( 2014-11-17 11:51:15 -0600 )edit

I cannot even see my comment...

thdrksdfthmn gravatar imagethdrksdfthmn ( 2014-11-18 08:33:54 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-11-16 23:49:12 -0600

Hi @Araneo!

You can compute the Gabor Edge of an image as follows. You can play around with these parameters to find your desired edges.

#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;
}
edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-11-16 02:57:57 -0600

Seen: 1,849 times

Last updated: Nov 16 '14