为什么将图像放在黑色背景上会导致numpy问题?

时间:2018-12-01 09:12:57

标签: python-3.x numpy opencv

import cv2
import numpy as np


def mycvshow(imagein, title='Image'): #title can be specified or left to the default
    cv2.imshow(title,imagein)
    cv2.waitKey()
    #cv2.destroyWindow(title)


img_gray=cv2.imread('cat.jpg',0)
big_picture=np.zeros((img_gray.shape[0]+1000,img_gray.shape[1]+1000))
big_picture[0:img_gray.shape[0],0:img_gray.shape[1]]=img_gray
mycvshow(big_picture)

以上是我的代码。我读了一张灰度图像,然后将其放入一个大的零矩阵。我希望它返回一张黑色背景的猫的图片,但是它破坏了mycvshow函数,并在黑色背景上显示了几乎全白的猫图片,并且显示该图像的窗口似乎也有问题。如果我只写mycvshow(img_gray),一切都会顺利进行。

0 个答案:

没有答案