PIL库参考: http://www.cn blogs.com/yinxiang nan-Charles/p/5928689.html
importnumpyasnpfrompilimportimage #图像im=image.open (' e :/liuying/pictures/test.png ' ) im.show ) (print ) 读取的数据类型print(thesizeofim: (,im.size ) #数据的大小im_array=NP.array(im ) )转换为array数组print ) thedatate
thedatatypeofimclass ' pil.pngimageplugin.png image file ' thesizeofim : (203,137 ) thedatatypeofim _ array class ' nu
这里有问题。 将显示的图像另存为时,只能保存BMP格式。 我有点疑问。 另外,保存的图像无法正常显示。
skimage库参考: https://www.Jian Shu.com/p/e 8d 058767 DFA
fromskimageimportioim=io.im read (e :/liuying/pictures/test.png ' ) io.imshow ) im ) print ) thedatatypeope
显示图像时会自动添加坐标轴,如thedatatypeofimclass ' numpy.nd array ' theshapeofimg : (137,203,4 )中所示。
matplotlib库importmatplotlib.pyplotasplt # PLT图像importmatplotlib.imageasmpimg # MP img图像im=MP img.im read (e 3360/lead 用于显示lead的test.png'(print )、thedatatypeofim )、type ) )、读取的数据类型print )、theshapeofimg3360 )和im.shape )
thedatatypeofimclass ' numpy.nd array ' theshapeofimg : (137、203、4 )。
如果不想看到坐标轴,可以通过以下方法删除:
用于显示importmatplotlib.pyplotasplt # PLT图像。 用于读取importmatplotlib.imageasmpimg # MP img图像。 %matplotlib inline #最初是在python notebook上显示图像时嵌入的,但似乎不用也没有影响。 姑且先放一放im=MP img.im read (e :/liuying/pictures/test.png ) (print )、thedatatypeofim )、type ) (im ) im.shape ) #数据大小PLT.figure(image ) (plt.show ) #显示图像PLT.axis ) (off ) #坐标轴plt.show ) )似乎不显示也不会影响结果