上一篇文章生成了三张图像,现在正在对其中一张进行图像读取和数据转换。
其中. convert('l )很重要,读取的像素值是包含RGB分量值的数组,如果不进行变换,直接与220进行比较,报告错误。
frompilimportimageimportmatplotlib.pyplotaspltimportnumpyasnpimage=image.open (d :/python/generate/mixrowcolorate PLT.figure (single ) (plt.show ) image (PLT.show ) ) img=NP.array (image ) print (img ) image.show ) (forxinrange(image.size[0] ) : foryinrange (image.size [1] ) : # print (image.getpixixt y ) ) 2203360 Iman y ),255 ) image.show(img1=NP.array ) image ) print ) img1) image.save (' d :/python/test.png ' ) moduler
pip安装列表
因为有多个版本的python发生冲突。
python3- m pip安装矩阵