How to apply gabor filter to images in opencv?

I have wavelets with gabor filter code, this is something like this. wavelets

but I don’t know how to use it in my image? I know that there are some ways to use Matlab, i.e. matlab . but I use opencv, and I am very new to this field and matlab, I do not know how to write opencv code from matlab code, so waht should I do this with opencv? Many thanks!

**** Update ****
I tried the @berak method and this is the original image

and this is after I applied the filter enter image description hereonly all white and there is nothing left, below my parameters,

int kernel_size = 31;
double sig = 1, th = 0, lm = 1.0, gm = 0.02, ps = 0;
cv::Mat kernel = cv::getGaborKernel(cv::Size(kernel_size, kernel_size), sig, th, lm, gm, ps);
cv::filter2D(src_f, dest, CV_32F, kernel);

Is there something wrong with my setup?

+4
2

, img float,

:

cv::Mat kernel = cv::getGaborKernel(cv::Size(kernel_size,kernel_size), sig, th, lm, gm, ps);

filter2D:

cv::filter2D(src_f, dest, CV_32F, kernel);

[]

** , , , 1- .

** imshow , - 1.0, .

( , /, )

Mat in = imread("XfNal.jpg",0);          // load grayscale
Mat dest;
Mat src_f;
in.convertTo(src_f,CV_32F);

int kernel_size = 31;
double sig = 1, th = 0, lm = 1.0, gm = 0.02, ps = 0;
cv::Mat kernel = cv::getGaborKernel(cv::Size(kernel_size,kernel_size), sig, th, lm, gm, ps);
cv::filter2D(src_f, dest, CV_32F, kernel);

cerr << dest(Rect(30,30,10,10)) << endl; // peek into the data

Mat viz;
dest.convertTo(viz,CV_8U,1.0/255.0);     // move to proper[0..255] range to show it
imshow("k",kernel);
imshow("d",viz);
waitKey();

clip_gabor

+10

change sigma = 3 lambda = 36 theta = 116 psi = 274

-3

Source: https://habr.com/ru/post/1536544/


All Articles