gpt4 book ai didi

opencv - 为什么 OpenCV 在灰度图像上绘图时不应用抗锯齿?

转载 作者:太空宇宙 更新时间:2023-11-03 21:21:33 25 4
gpt4 key购买 nike

这是我用来创建新图像、在其上画一个圆并显示它的代码:

import numpy as np
import cv2

# create 50x50 image, filled with white
img = np.ones((50,50))
# draw a circle onto the image
cv2.circle(img, (25,25), 10, 0, 2, lineType=cv2.LINE_AA)
# show the image on the screen
cv2.imshow("i", img)
cv2.waitKey(0)
cv2.destroyAllWindows()

但是,似乎没有应用抗锯齿(我将图像放大了 10 倍): enter image description here

我做错了什么?

最佳答案

如果图像深度不是CV_8Uline_type会自动设置为8

来自 opencv/modules/imgproc/src/drawing.cpp :

if( line_type == CV_AA && img.depth() != CV_8U )
line_type = 8;

由于 numpy.ones 的类型默认为 numpy.float64,因此您将丢失抗锯齿线。

关于opencv - 为什么 OpenCV 在灰度图像上绘图时不应用抗锯齿?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44031438/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com