✨博客主页:王乐予🎈
✨年轻人要:Living for the moment(活在当下)!💪
🏆推荐专栏:【图像处理】【千锤百炼Python】【深度学习】【排序算法】
话不多说,直接看代码!
import cv2
import os
import numpy as np
def read_path(file_pathname):
for filename in os.listdir(file_pathname):
print(filename)
img = cv2.imread(file_pathname+'/'+filename)
image = np.power(img, 0.8) # 对像素值指数变换
cv2.imwrite(r"C:\Users\Lenovo\Desktop\change" + "/" + filename, image)
read_path(r"C:\Users\Lenovo\Desktop\original")
这里使用np.power()
指数变换函数对图像像素值进行处理,参数设置方式如下:
- 小于1:降低图像亮度
- 大于1:提高图像亮度
图片展示如下: