本文介绍了使用OpenCV进行gabor边缘检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在OpenCV中,我使用以下方法检索了9:9矩阵的Gabor内核以进行图像处理:

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?

我正在尝试将Gabor小波滤波器组合在一起进行边缘检测.

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

就矩阵的卷积而言,它似乎是用opencv"filter2d"方法实现的,并且可以在Android OpenCV api的Imgproc类中找到.

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.

推荐答案

您需要规范化内核.

只需在内核矩阵上循环,即可计算出值的总和.然后再次循环以将每个值除以和.这样可以确保您的内核不会改变总体亮度.

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.

这篇关于使用OpenCV进行gabor边缘检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 00:30