"imagio.imsave" 对比 "imageio.core.util.Array.tofile"

"imagio.imsave" vs "imageio.core.util.Array.tofile"

我通过将一些 MATLAB 图像分析代码转换为 Python 来扩展我有限的 Python 知识。我正在关注 Image manipulation and processing using Numpy and Scipy。 2.6.1 节中的代码使用 imageio.imsaveface.tofile 保存图像,其中 type(face)=<class 'imageio.core.util.Array>'.

我想了解为什么有两种导出图像的方法。我尝试了网络搜索 tofile,但找到了 numpy.ndarray.tofile。它非常稀疏,似乎并不特定于图像。我也找过 imageio.core.util.Array.tofile,但找不到任何东西。

为什么有两种导出文件的方式?为什么 imageio.core.util.Array.tofile 似乎在网上找不到?

区别在于两个函数在文件中写了什么。

imageio.imsave() 以 JPEG/PNG 格式保存传统图像,如图片或照片,可以使用 GIMP 等图像查看器查看,feheogPhotoshop 或 MSxPaint。

tofile() 以 Numpy 兼容的格式保存,只有 Numpy(和少数其他 Python 工具)使用。