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 original image
My Gabor filtering implementation (gabor1.jpg) at the orientation 0 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]);
have a look at this tutorial and this answer of @berak in SO
@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.
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};
Really appreciate your help. Thank you, berak! The results look as expected now.
Hi berak. I need learn the adaptive Gabor . Could you provide some code and directions?
do we have an adaptive gabor even ?
Yes. And I downloaded some articles about that from google.
so, if you got a nice solution using opencv, - don't hesitate to add that as an answer here ;) !!
hi berak please help me with finding the right code for finger print enhancement using c++ here is my email [email protected]