【发布时间】:2015-10-09 01:05:18
【问题描述】:
我正在尝试使用 opencv 在 python 中显示图像,上面有一个侧窗格。当我使用np.hstack 时,主图片变得无法辨认,只有少量颜色。这是我的代码:
img = cv2.imread(filename)
img_with_gt, gt_pane = Evaluator.return_annotated(img, annotations)
both = np.hstack((img_with_gt, gt_pane))
cv2.imshow("moo", both)
cv2.waitKey(0)
cv2.destroyAllWindows()
这是生成的图片
但如果我查看img_with_gt,它看起来是正确的。
甚至可以使用gt_pane
我似乎无法弄清楚为什么会这样。
【问题讨论】:
-
两张图片的数据类型是什么?具体来说,当您在 REPL 中执行
img_with_gt.dtype和gt_pane.dtype时会发生什么?他们是同一个班级吗? -
gt_pane是 float64,img_with_gt是 uint8 ..我在对np.zeroes的调用中使用可选的dtype更改了结构,它运行良好。谢谢!!如果你回答,我可以给你打勾。 -
好了。这是数据类型的冲突。是的,让我现在写一个答案:)
标签: python opencv numpy image-processing