How to successfully implement a Gabor filtering?

asked 2015-06-08 05:06:59 -0500

cv_new gravatar image

I don't quite understand why the result of my Gabor filtering implementation is quite different from my reference information. As shown in Figure 8, there are more gray value differences existing in those reference images, while there are only binary values shown in my resulting images. Could anyone give any suggestions to my implementation? Thanks in advance.

The demo of Gabor filtering The demo of Gabor filtering

The original image The original image

My Gabor filtering implementation (gabor1.jpg) at the orientation 0 degree My Gabor filtering implementation (gabor1.jpg) at the orientation 0 degree

My Gabor filtering implementation (gabor2.jpg) at the orientation 45 degree My Gabor filtering implementation (gabor2.jpg) at the orientation 45 degree

The code of my Gabor filtering implementation

Mat inImg = imread("C:\\Images\\testch.bmp",0);  // read in greyscale   
        resize(inImg,reImg,Size(66,96),0,0,INTER_NEAREST);
        reImg.convertTo(src_f,CV_32F);

        int kernel_size = 3;
        double sig = 5, th = 0, lm = 8, gm = 0.02, ps = 0;
        vector<Mat> destArray;
        double theta[4] ;
        Mat temp;

        theta[0] = 0;
        theta[1] = 45;
        theta[2] = 90;
        theta[3] = 135;

        for (int j = 0; j<4; j++)
        {
            Mat kernel1;
            Mat dest;
            kernel1 = cv::getGaborKernel(cv::Size(kernel_size,kernel_size), sig, theta[j], lm, gm, ps, CV_32F);
            filter2D(src_f, dest, CV_32F, kernel1);

            destArray.push_back(dest);              
        }

        imwrite("C:\\Images\\gabor1.jpg",destArray[0]);
        imwrite("C:\\Images\\gabor2.jpg",destArray[1]);
        imwrite("C:\\Images\\gabor3.jpg",destArray[2]);
        imwrite("C:\\Images\\gabor4.jpg",destArray[3]);
edit retag flag offensive close merge delete

Comments

1

have a look at this tutorial and this answer of @berak in SO

theodore gravatar imagetheodore ( 2015-06-08 07:02:02 -0500 )edit

@theodore, I understand the tutorial, but according to the tutorial I still cannot make the same result as Fig.8. Now that all orientiation of gabor images almost look like the same. Since I want to do the character recognition, if there is not enough features for me to extract, I worry that I cannot make the recognition process good enough.

cv_new gravatar imagecv_new ( 2015-06-08 21:12:09 -0500 )edit

just keep on trying, vary your params a bit (e.g. a larger kernel size)

int kernel_size = 9; double sig = 5, th = 0, lm = 4, gm = 0.04, ps = CV_PI/4; double theta[4] = {0,15,30,45};

image description

berak gravatar imageberak ( 2015-06-09 01:06:58 -0500 )edit
1

Really appreciate your help. Thank you, berak! The results look as expected now.

cv_new gravatar imagecv_new ( 2015-06-09 02:09:10 -0500 )edit

Hi berak. I need learn the adaptive Gabor . Could you provide some code and directions´╝č

Sheng Liu gravatar imageSheng Liu ( 2015-06-18 03:07:51 -0500 )edit

do we have an adaptive gabor even ?

berak gravatar imageberak ( 2015-06-18 03:53:27 -0500 )edit
1

Yes. And I downloaded some articles about that from google.

Sheng Liu gravatar imageSheng Liu ( 2015-06-18 04:52:31 -0500 )edit

so, if you got a nice solution using opencv, - don't hesitate to add that as an answer here ;) !!

berak gravatar imageberak ( 2015-06-18 04:58:38 -0500 )edit

hi berak please help me with finding the right code for finger print enhancement using c++ here is my email seliyeenatye@gmail.com

selomie gravatar imageselomie ( 2017-06-23 08:26:52 -0500 )edit