当前位置:网站首页>利用七种方法对一个文件夹里面的所有图像进行图像增强实战
利用七种方法对一个文件夹里面的所有图像进行图像增强实战
2022-07-07 15:40:00 【AI炮灰】
# coding = utf-8
import cv2
from PIL import Image
from PIL import ImageEnhance
from numpy.ma import array
import numpy as np
import os
# 批量处理代码
rootdir = 'F:/danzi/数据/4' # 指明被遍历的文件夹
def high_bright(currentPath, filename, targetPath):
# 读取图像
image = Image.open(currentPath)
image_cv = cv2.imread(currentPath)
# image.show()
# 增强亮度 bh_
enh_bri = ImageEnhance.Brightness(image)
brightness = 1.07
image_brightened_h = enh_bri.enhance(brightness)
# image_brightened_h.show()
image_brightened_h.save(targetPath+ '1' + filename) # 保存
def low_bright(currentPath, filename, targetPath):
image = Image.open(currentPath)
image_cv = cv2.imread(currentPath)
# 降低亮度 bl_
enh_bri_low = ImageEnhance.Brightness(image)
brightness = 0.87
image_brightened_low = enh_bri_low.enhance(brightness)
# image_brightened_low.show()
image_brightened_low.save(targetPath&#
边栏推荐
猜你喜欢
Mrs offline data analysis: process OBS data through Flink job
请将磁盘插入“U盘(H)“的情况&无法访问 磁盘结构损坏且无法读取
深入浅出图解CNN-卷积神经网络
【TPM2.0原理及应用指南】 16、17、18章
第2章搭建CRM项目开发环境(搭建开发环境)
Sator a lancé le jeu web 3 "satorspace" et a lancé huobi
User defined view essential knowledge, Android R & D post must ask 30+ advanced interview questions
Functions and usage of viewswitch
Matplotlib绘制三维图形
【信息安全法律法規】複習篇
随机推荐
Functions and usage of tabhost tab
【TPM2.0原理及应用指南】 16、17、18章
Mysql 索引命中级别分析
serachview的功能和用法
Leetcode brush questions day49
PLC: automatically correct the data set noise, wash the data set | ICLR 2021 spotlight
麒麟信安加入宁夏商用密码协会
L1-027 出租(Lua)
Create dialog style windows with popupwindow
Notification is the notification displayed in the status bar of the phone
Repair method of firewall system crash and file loss, material cost 0 yuan
With the latest Alibaba P7 technology system, mom doesn't have to worry about me looking for a job anymore
无法链接远程redis服务器(解决办法百分百)
Jenkins发布uniapp开发的H5遇到的问题
TabHOST 选项卡的功能和用法
请将磁盘插入“U盘(H)“的情况&无法访问 磁盘结构损坏且无法读取
赋能智慧电力建设 | 麒麟信安高可用集群管理系统,保障用户关键业务连续性
What is cloud computing?
DatePickerDialog和trimepickerDialog
Enum + Validation 的个人最佳实践 demo 分享