2024-06-01 00:15:43 发布
网友
我想把图像想象成矩阵。我使用了这个答案透视图,the 2nd answer并使用matplotlib.image模块。
现在当我试图打印矩阵时,由于图像由大量像素组成,所以矩阵没有完全显示出来。如何查看完整的矩阵?
我使用的是Anaconda编译器和Spyder作为IDE,所有的最新版本。
可以使用matplotlib读取图像,然后将其另存为文件
In [21]: import json In [22]: from matplotlib import image In [23]: f = open("out.json", "w") In [24]: c = image.imread("02.jpg") In [25]: f.write(json.dumps(c.tolist(), indent=4)) Out[25]: 10925444 In [26]: f.close()
可以使用matplotlib读取图像,然后将其另存为文件
相关问题 更多 >
编程相关推荐