Python 中输出数组中的全部元素

只需要在开头加上一句即可

import numpy as np
np.set_printoptions(threshold=np.inf)

Python 输出到文本中
参考:https://blog.csdn.net/u010624166/article/details/80140002

import sys
print " 	"#里面为你需要输出的内容
output=sys.stdout
outputfile=open('output.txt', 'a')
sys.stdout=outputfile

若输出中带有中文,则添加

type=sys.getfilesystemencoding()#python编码转换到系统编码输出

整理关于Python读取图像的像素
参考:https://blog.csdn.net/search7/article/details/75528537

若用PIL(pillow)则

from PIL import Image
img=Image.open('0.png')
img_array=img.load()

然后就可以通过img_array[x,y]来读取像素值了
另外img.size查看图像的大小,也可以通过img_arrayx,y来设置RGB像素值

为了想要看到所有的像素值,所以转换成numpy格式如上读取

import numpy as np
import cv2
img=cv2.imread('0.png', 'a')

猜你喜欢

转载自blog.csdn.net/qq_17130909/article/details/83178158
今日推荐