3
votes

In OpenCV I retrieve a Gabor kernel for image processing which is a 9:9 matrix using:

Imgproc.getGaborKernel(...)

I have a gray matrix of the original image. (i'm not even sure if the kernel is supposed to be the size of the image or just a small segment, I'm fairly certain of the small kernel)

How do I convolve the two and get the output of the convolution?

I'm trying to put together a Gabor wavelet filter for edge detection.

EDIT: as far as convolution of matrices seems to be concerned it looks like the opencv "filter2d" method is what is used to do it and is found in Imgproc class of Android OpenCV api.

However when I do my convolution and put it to the screen its just a black image.

Size size = new Size(9,9);
Mat gaborKernel = Imgproc.getGaborKernel(size, 3.0, -Math.PI/4, Math.PI, 10.0, Math.PI*0.5, CvType.CV_64F);
Imgproc.filter2D(intermediate, output, -1, gaborKernel);
Bitmap temp = Bitmap.createBitmap(intermediate.cols(), intermediate.rows(), Config.ARGB_8888);
Utils.matToBitmap(output, temp);

I did a system output to see the values and all of the values are extremely small as seen below.

Gabor values row by row

1
Some code would be helpful, as well as the Gabor kernel itself. - mbrenon
Could you post your 10x10 gabor kernel you obtained? - Máthé Endre-Botond

1 Answers

2
votes

You need to normalize your kernel.

Just loop over the kernel matrix, calculate the sum of values. Then loop again to divide each value to the sum. This ensures that your kernel does not change the overal brightness.