Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python-尝试使用PIL的Image.fromarray保存numpy数组时出现TypeError_Python_Numpy_Python Imaging Library_Typeerror - Fatal编程技术网

Python-尝试使用PIL的Image.fromarray保存numpy数组时出现TypeError

Python-尝试使用PIL的Image.fromarray保存numpy数组时出现TypeError,python,numpy,python-imaging-library,typeerror,Python,Numpy,Python Imaging Library,Typeerror,我一直在尝试使用PIL在numpy阵列的帮助下加载和存储图像。 我试图加载尺寸为192x192的图像,将其填充为256x256,然后将其存储回去。 以下是我正在尝试运行的脚本: 错误: TypeError:无法处理此数据类型:(1,1,4),您无意中创建了浮点数组。更改为: t = np.zeros((256,256,4), dtype=np.uint8) 谢谢,成功了。我原以为这和尺寸有关。 TypeError: Cannot handle this data type: (1, 1

我一直在尝试使用PIL在numpy阵列的帮助下加载和存储图像。
我试图加载尺寸为192x192的图像,将其填充为256x256,然后将其存储回去。
以下是我正在尝试运行的脚本:


错误:

TypeError:无法处理此数据类型:(1,1,4),您无意中创建了浮点数组。更改为:

t = np.zeros((256,256,4), dtype=np.uint8)

谢谢,成功了。我原以为这和尺寸有关。
TypeError: Cannot handle this data type: (1, 1, 4), <f8
t = np.zeros((256,256,4), dtype=np.uint8)