【发布时间】:2023-04-05 07:39:01
【问题描述】:
我目前正在尝试将圆圈外的所有内容涂黑。 我正在使用以下代码行绘制圆圈:
cv::Point center(cvRound(circles[i][0]), cvRound(circles[i][1])); // CVRound converts floating numbers to integer
int radius = cvRound(circles[i][2]); // Radius is the third parameter [i][0] = x [i][1]= y [i][2] = radius
circle( image, center, 3, cv::Scalar(0,255,0), -1, 8, 0 ); // Drawing little circle to Image Center , next Line of Code draws the real circle
circle( image, center, radius, cv::Scalar(0,0,255), 3, 8, 0 ); // Circle(img, center, radius, color, thickness=1, lineType=8, shift=0)
如果我有一个半径和我的圆的中心,那么将所有圆形黑色绘制的最佳方法是什么? OpenCV 是否提供了一种简单的机制来执行此操作,或者我是否应该遍历图像的所有像素并根据位置将它们着色为黑色?
【问题讨论】:
-
创建一个蒙版图像(只需在与原始图像大小相同的黑色图像上绘制白色圆圈),然后将 bitwise_and() 与您的图像和蒙版一起使用..
标签: opencv image-processing feature-detection