我正在尝试对以numpy数组表示的图像数据集进行预处理,图像形状为(28, 28)
,将它们重新缩放为(10, 10)
。我写了以下的函数:
import cv2 as cv
def resize_dataset(images):
resized_images = []
for img in images:
img = img.reshape((28,28))
resized_img = cv.resize(img, dsize=(10, 10))
resized_images.append(resized_img)
return numpy.array(resized_images)
但是当我尝试重新调整它们的大小时,cv.resize
函数会返回以下错误:
error: OpenCV(4.0.0) /io/opencv/modules/imgproc/src/resize.cpp:3662: error: (-215:Assertion failed) func != 0 in function 'resize'
在谷歌上,我只找到那些写C++的人遇到相同错误但做的事情不一样,例如这个问题:调整图像大小和更改深度以及这个:http://answers.opencv.org/question/19715/error-215-func-0-in-function-convertto/。如何修复?
int64
一起使用吗?我还发现它不能与int32
一起使用,但可以与uint8
一起使用。 - Neb