int16 和 int64 的区别

Diffenrence in int16 and int64

为什么在创建黑色图像时设置dtype = np.int64,我不能在图像上画圆,而dtype = np.int16我可以在黑色图像上画圆。

black_img = np.zeros(shape = (512,512,3),dtype = np.int64)
cv2.circle(img = black_img,center = (400,100),radius = 50,color = (255,0,0),thickness = 8)

输出:

plt.imshow(black_img)

imshow() 函数显示没有圆圈的黑色图像

同时 dtype = np.int16

输出:

array([[[0, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        ...,
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0]],

       [[0, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        ...,
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0]],

       [[0, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        ...,
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0]],

       ...,

       [[0, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        ...,
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0]],

       [[0, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        ...,
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0]],

       [[0, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        ...,
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0]]], dtype=int16)

请解释。提前谢谢你。

OpenCV 绘图函数适用于特定格式的矩阵。

它们被枚举 here。请注意,没有 64 位整数像素的格式,因此 OpenCV 无法使用此类矩阵进行绘制。