Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to successfully implement a Gabor filtering?

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