且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用OpenCV将偏导数高斯核应用于图像?

更新时间:2023-02-27 11:19:13

OpenCV没有内置函数来计算高斯偏导数.但是您可以使用 cv::getGaussianKernel cv::filter2D 这样做.

OpenCV doesn't have built-in function to calculate Gaussian partial derivatives. But you may use cv::getGaussianKernel and cv::filter2D to do so.

例如:

  cv::Mat kernel = cv::getGaussianKernel(3, 0.85, CV_32F);
  kernel = kernel.reshape(1, 1);
  cv::filter2D(img, img, CV_8U, kernel);

请注意,cv::getGaussianKernel返回列过滤器,因此您需要reshape将其水平放置.

Please note that cv::getGaussianKernel returns column filter, so you need reshape to make it horizontal.