opencv中抗锯齿圆呈锯齿状

发布于 2025-01-11 01:20:22 字数 864 浏览 0 评论 0原文

这看起来像是一个常见的 OpenCV 圆形配方,会为所绘制的圆形产生真正的锯齿状边缘。这是最低限度可行的可重现代码:

import cv2
import numpy as np

image = np.zeros((512,512,3), np.uint8) 
cv2.circle(image, (350, 350), 200, (15,75,50), cv2.FILLED)
cv2.imshow("Circle", image)
cv2.waitKey(0)
cv2.destroyAllWindows()

锯齿状圆圆周的图像

在非填充圆的情况下可能会好一点(使用 lineType=cv2.LINE_AA 时):

类似于previous

但有时绘制既填充又具有良好圆周边缘的圆圈会很好。

我想知道这个结果是否可以在使用 OpenCV 的框架内得到改进,尽管 OpenCV 可能不会尝试成为一个像素完美的绘图库。

预先感谢您的帮助,因为我缩小了 OpenCV 和 Pyglet 之间的选择范围,以实现特定的计算机视觉与图形实现。而且,即使只是在一些 OpenCV 负载应用程序中随意使用形状绘图,拥有视觉上令人愉悦的传统形状也是很好的。

It may seem like a common OpenCV recipe for a circle yields really jagged edges to the circles being drawn. Here's minimally viable reproducible code:

import cv2
import numpy as np

image = np.zeros((512,512,3), np.uint8) 
cv2.circle(image, (350, 350), 200, (15,75,50), cv2.FILLED)
cv2.imshow("Circle", image)
cv2.waitKey(0)
cv2.destroyAllWindows()

image of jagged circle circumference

It's perhaps a little better in the case of a non-filled circle (when using lineType=cv2.LINE_AA):

similar to previous

But it's sometimes nice to draw circles which are both filled and have a good edge to their circumference at the same time.

I wonder if this outcome can be improved within the framework of using OpenCV, even though OpenCV probably does not try to be a pixel perfect drawing library.

Thanks in advance for your help as I narrow down my choice between OpenCV and Pyglet for a certain computer vision with graphics implementation. And also because it would be nice to have visually pleasing conventional shapes even for just your haphazard use of shape drawing in some OpenCV laden applications.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

隔岸观火 2025-01-18 01:20:23

在同一调用中使用两者 thickness=cv.FILLED lineType=cv.LINE_AA

您应该始终查阅您所使用的技术的文档。

import cv2
import numpy as np

image = np.zeros((512,512,3), np.uint8) 
cv2.circle(image, (350, 350), 200, (15,75,50), thickness=cv2.FILLED, lineType=cv2.LINE_AA)
cv2.imshow("Circle", image)
cv2.waitKey(0)
cv2.destroyAllWindows()

Use both thickness=cv.FILLED and lineType=cv.LINE_AA in the same call.

You should always consult the documentation of the technologies you use.

import cv2
import numpy as np

image = np.zeros((512,512,3), np.uint8) 
cv2.circle(image, (350, 350), 200, (15,75,50), thickness=cv2.FILLED, lineType=cv2.LINE_AA)
cv2.imshow("Circle", image)
cv2.waitKey(0)
cv2.destroyAllWindows()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文