#--coding:utf-8--
import cv2
import numpy as np
import os
def gamma_trans(img,gamma):#gamma函数处理
gamma_table=[np.power(x/255.0,gamma)*255.0 for x in range(256)]#建立映射表
gamma_table=np.round(np.array(gamma_table)).astype(np.uint8)#颜色值为整数
return cv2.LUT(img,gamma_table)#图片颜色查表。另外可以根据光强(颜色)均匀化原则设计自适应算法。
def nothing(x):
pass
cv2.namedWindow("demo",0)#将显示窗口的大小适应于显示器的分辨率
cv2.createTrackbar('Value of Gamma','demo',100,1000,nothing)#使用滑动条动态调节参数gamma
data_base_dir="C:\\Users\\HUANG\\Desktop\\pict"#输入文件夹的路径
outfile_dir="C:\\Users\\HUANG\\Desktop\\pictout"#输出文件夹的路径
processed_number=0#统计处理图片的数量
print "press enter to make sure your operation and process the next picture"
for file in os.listdir(data_base_dir):#遍历目标文件夹图片
read_img_name=data_base_dir+'//'+file.strip()#取图片完整路径
image=cv2.imread(read_img_name)#读入图片
while(1):
value_of_gamma=cv2.getTrackbarPos('Value of Gamma','demo')#gamma取值
value_of_gamma=value_of_gamm
python opencv-批量调整图片的曝光率
最新推荐文章于 2025-10-30 13:40:16 发布

最低0.47元/天 解锁文章
1823





