python PIL模块使用案例
程序员文章站
2022-03-05 13:29:24
...
整体思路:
求解的所有文件固定位置灰度值平均值,并作图
from PIL import Image
import os
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as ani
os.chdir('D:\python\work\工作平台\diff-gate time')
#建立所有文件名称的list,使用循环异常打开
all_filename=os.listdir()
print(all_filename)
def sov_ever(filename):
imgData = np.fromfile(filename, dtype='uint16')
img=imgData.reshape(3072, 3072, 1)
img_select=[]
a=1844
b=576
for i in range(0,900):
for j in range(0,900):
img_select.append(img[a+i][b+j])
LSB=np.mean(img_select)
return LSB
all_LSB=[]
for i in all_filename:
all_LSB.append(sov_ever(i))
time_TFT=[0.01,0.02,0.03,0.04,0.05,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.1,2.2,2.5,3.0,20]
'''time_TFT=[0.05,0.1,0.15,0.2,0.25,0.3,0.35,0.4,0.45,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.1,2.2,2.3,2.4,2.5,2.6,3]'''
all_Q=[1.0361776332118499e-13, 1.0800633037418517e-13, 1.0782525972348122e-13, 1.0874002909511083e-13, 1.0841649401359255e-13, 1.346201053175926e-13, 3.6722037927125916e-13, 7.615369384489259e-13, 1.2419614776019258e-12, 1.7504245357723332e-12, 2.2607854325087408e-12, 2.7625700546931853e-12, 3.2278828009051103e-12, 3.677257915361295e-12, 4.0973901983208135e-12, 4.493080099101111e-12, 4.860517600962074e-12, 5.20287687700248e-12, 5.521439504284851e-12, 5.813996713567333e-12, 5.865734555233184e-12, 6.323819449186258e-12, 6.548809662025184e-12, 6.756645500889036e-12, 6.94236060057411e-12, 6.999836448986777e-12, 6.9998574499999986e-12, 6.9998574499999986e-12, 6.9998574499999986e-12,7e-12]
'''for i in all_LSB:
all_Q.append(((i*61.035*1e-6)-0.5)*2e-12)
print(all_Q)'''
fig=plt.figure()
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
plt.plot(time_TFT,all_Q)
plt.title('收集电荷量与gate打开时间关系曲线')
plt.xlabel('TFT打开时间/us')
plt.ylabel('收集电荷量/C')
animator = ani.FuncAnimation(fig, buildmebarchart, interval = 100)
plt.show()
'''print(all_LSB)
#代入电荷求解公式
Q=[]
q.append()'''
#画函数
结果:
![在这里插入图片描述](https://img-blog.csdnimg.cn/20201204142441345.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl81MTU0OTY5MA==,size_16,color_FFFFFF,t_70)
上一篇: 剑指Offer-32. 整数中1出现的次数(从1到n整数中1出现的次数)
下一篇: TCP协议的特点
推荐阅读
-
python uuid模块使用实例
-
Python使用matplotlib模块绘制图像并设置标题与坐标轴等信息示例
-
Python使用re模块实现信息筛选的方法
-
Python中使用select模块实现非阻塞的IO
-
Python使用自带的ConfigParser模块读写ini配置文件
-
Python使用lxml模块和Requests模块抓取HTML页面的教程
-
Python使用dis模块把Python反编译为字节码的用法详解
-
Python使用SocketServer模块编写基本服务器程序的教程
-
Python 使用requests模块发送GET和POST请求的实现代码
-
Python Paramiko模块的安装与使用详解