当前位置:网站首页>利用七种方法对一个文件夹里面的所有图像进行图像增强实战
利用七种方法对一个文件夹里面的所有图像进行图像增强实战
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&#
边栏推荐
- datepicket和timepicket,日期、时间选择器的功能和用法
- 【饭谈】Web3.0到来后,测试人员该何去何从?(十条预言和建议)
- Nerf: the ultimate replacement for deepfake?
- 本周小贴士#134:make_unique与私有构造函数
- 99%的人都不知道|私有化部署还永久免费的即时通讯软件!
- Numberpick的功能和用法
- Siggraph 2022 best technical paper award comes out! Chen Baoquan team of Peking University was nominated for honorary nomination
- calendarview日历视图组件的功能和用法
- Flash build API Service - generate API documents
- 本周小贴士#135:测试约定而不是实现
猜你喜欢
【网络攻防原理与技术】第1章:绪论
第3章业务功能开发(安全退出)
请将磁盘插入“U盘(H)“的情况&无法访问 磁盘结构损坏且无法读取
TabHOST 选项卡的功能和用法
LeetCode刷题day49
A tour of grpc:03 - proto serialization / deserialization
User defined view essential knowledge, Android R & D post must ask 30+ advanced interview questions
How to choose the appropriate automated testing tools?
赋能智慧电力建设 | 麒麟信安高可用集群管理系统,保障用户关键业务连续性
Share the latest high-frequency Android interview questions, and take you to explore the Android event distribution mechanism
随机推荐
Matplotlib绘图界面设置
Mrs offline data analysis: process OBS data through Flink job
本周小贴士#135:测试约定而不是实现
alertDialog創建对话框
Sator launched Web3 game "satorspace" and launched hoobi
无法链接远程redis服务器(解决办法百分百)
actionBar 导航栏学习
Lex & yacc of Pisa proxy SQL parsing
简单的loading动画
Functions and usage of tabhost tab
Linux 安装mysql8.X超详细图文教程
数值 - number(Lua)
Flash build API Service - generate API documents
The computer cannot add a domain, and the Ping domain name is displayed as the public IP. What is the problem? How to solve it?
第2章搭建CRM项目开发环境(数据库设计)
本周小贴士#140:常量:安全习语
【信息安全法律法規】複習篇
责任链模式 - Unity
Numberpick的功能和用法
Flask build API service SQL configuration file