问题
I'm trying reproduce results from a paper, in which they convolve the image with an horizontal partial derivative of a Gaussian kernel. I haven't found any way to achieve that with OpenCV. Is that possible ?
Do I have to get Gaussian filter and then compute the partial derivatives by hand ?
回答1:
OpenCV doesn't have built-in function to calculate Gaussian partial derivatives. But you may use cv::getGaussianKernel and cv::filter2D to do so.
For example:
cv::Mat kernel = cv::getGaussianKernel(3, 0.85, CV_32F);
kernel = kernel.reshape(1, 1);
cv::filter2D(img, img, CV_8U, kernel);
Please note that cv::getGaussianKernel
returns column filter, so you need reshape
to make it horizontal.
来源:https://stackoverflow.com/questions/35012080/how-to-apply-a-partial-derivative-gaussian-kernel-to-an-image-with-opencv