本文主要是介绍opencv dots_image_kernel,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1,opencv dots_image_kernel
// halcon dots_image kernel估算(d=5)
cv::Mat getDotKernel(int d = 5){// 保证d为正的奇数d |= 0x01;cv::Mat kernel = cv::Mat::zeros(d + 2, d + 2, CV_8UC1);int cx = kernel.cols / 2;int cy = kernel.rows / 2;int cnt255 = 0, cnt128 = 0, cnt0 = 0;for (int row = 0; row < kernel.rows; ++row) {for (int col = 0; col < kernel.cols; ++col) {float dis = std::sqrt(std::pow(col - cx, 2) + std::pow(row - cy, 2));if (dis < d / 2.0){kernel.at<uchar>(row, col) = 255;cnt255++;}else if (dis < d / 2.0 + 1.0){kernel.at<uchar>(row, col) = 128;cnt128++;}else {kernel.at<uchar>(row, col) = 0;cnt0++;}}}//cv::imwrite("kernel8u.0.png", kernel);//for (int row = 0; row < kernel.rows; ++row) {for (i
这篇关于opencv dots_image_kernel的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!