当前位置:网站首页>利用七种方法对一个文件夹里面的所有图像进行图像增强实战
利用七种方法对一个文件夹里面的所有图像进行图像增强实战
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&#边栏推荐
- 大笨钟(Lua)
- Establishment of solid development environment
- The top of slashdata developer tool is up to you!!!
- 麒麟信安操作系统衍生产品解决方案 | 存储多路径管理系统,有效提高数据传输可靠性
- Flask build API service SQL configuration file
- 【TPM2.0原理及应用指南】 5、7、8章
- 阿富汗临时政府安全部队对极端组织“伊斯兰国”一处藏匿点展开军事行动
- Sator launched Web3 game "satorspace" and launched hoobi
- 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?
- 如何在软件研发阶段落地安全实践
猜你喜欢
随机推荐
本周小贴士#134:make_unique与私有构造函数
Create dialog style windows with popupwindow
Smart logistics platform: make overseas warehouses smarter
The mail server is listed in the blacklist. How to unblock it quickly?
TabHOST 选项卡的功能和用法
Matplotlib绘制三维图形
本周小贴士#141:注意隐式转换到bool
[source code interpretation] | source code interpretation of livelistenerbus
notification是显示在手机状态栏的通知
Flask build API service SQL configuration file
Solid function learning
Show progress bar above window
User defined view essential knowledge, Android R & D post must ask 30+ advanced interview questions
How to mount the original data disk without damage after the reinstallation of proxmox ve?
【网络攻防原理与技术】第5章:拒绝服务攻击
alertDialog創建对话框
Sator launched Web3 game "satorspace" and launched hoobi
Function and usage of calendar view component
Siggraph 2022 best technical paper award comes out! Chen Baoquan team of Peking University was nominated for honorary nomination
Define menus using XML resource files









