b=ndimage.gaussian_filter(imagefile,5)
对python还不熟悉,无法理解这一点。
如何将b
保存为图像,b
属于“numpy.ndarray”类型?
试过这些,
一。
im = Image.fromarray(b)
im.save("newfile.jpeg")
Error: TypeError("Cannot handle this data type")
2。
imsave('newfile.jpg', b)
Error: ValueError: 'arr' does not have a suitable array shape for any mode.
将ndarray
保存到图像中的正确方法是什么?
编辑:
已解决:
im = Image.fromarray(b)
im.save('newfile.jpeg')
起作用了,我加载图像的方式是错误的
file = Image.open("abc.jpg")
imagefile = file.load()
//I was using imagefile after loading,which was not giving proper shape to reconstruct the image.加载后,我正在使用imagefile,它没有给出重建图像的正确形状。
//如果我使用文件(即打开后直接使用上述方法保存)
我认为最好的方法是使用
matplotlib
imshow
。使用
image
库:Matplotlib版本:
相关问题 更多 >
编程相关推荐