【问题标题】:Diffenrence in int16 and int64int16 和 int64 的区别
【发布时间】:2021-10-04 02:31:51
【问题描述】:

为什么在创建黑色图像时设置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)

请解释一下。提前谢谢你。

【问题讨论】:

    标签: python opencv geometry google-colaboratory


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-24
      • 2018-02-24
      • 1970-01-01
      相关资源
      最近更新 更多