参考:
https://stackoverflow.com/questions/7385465/resize-an-image-and-changing-its-depth
原因:
回答评论1
resize输入输出数值类型或插值类型缺失
because OpenCV resize is missing support for certain combinations of input and output depths (numeric types), and interpolation types
解决方案:
回答评论
转化类型
the image dtype was int64 (in Python). It worked as soon as I used uint8
我的情况是由于原本图片类型为int32 img.astype(‘uint8’)解决
img = cv2.imread("images/coffe.jpg") # 读取图像
dst1 = cv2.resize(img, (500, 500)) # 按照宽500像素、高500像素的大小进行缩放
image=dst1.astype('uint8')
print(image,image.shape)
问题解决