当前位置:网站首页>Use seven methods to enhance all the images in a folder
Use seven methods to enhance all the images in a folder
2022-07-07 17:40:00 【AI cannon fodder】
# coding = utf-8
import cv2
from PIL import Image
from PIL import ImageEnhance
from numpy.ma import array
import numpy as np
import os
# Batch processing code
rootdir = 'F:/danzi/ data /4' # Indicates the folder being traversed
def high_bright(currentPath, filename, targetPath):
# Read images
image = Image.open(currentPath)
image_cv = cv2.imread(currentPath)
# image.show()
# Enhance the brightness 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) # preservation
def low_bright(currentPath, filename, targetPath):
image = Image.open(currentPath)
image_cv = cv2.imread(currentPath)
# Decrease brightness 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&#
边栏推荐
猜你喜欢
随机推荐
第1章CRM核心业务介绍
Linux 安装mysql8.X超详细图文教程
在窗口上面显示进度条
【信息安全法律法规】复习篇
Solid function learning
Problems encountered in Jenkins' release of H5 developed by uniapp
机器视觉(1)——概述
yolo训练过程中批量导入requirments.txt中所需要的包
企业即时通讯软件是什么?它有哪些优势呢?
Establishment of solid development environment
【可信计算】第十一次课:TPM密码资源管理(三) NV索引与PCR
2021-06-28
数字化转型的主要工作
VSCode关于C语言的3个配置文件
Audio Device Strategy 音频设备输出、输入 选择 基于7.0 代码
L1-027 出租(Lua)
【网络攻防原理与技术】第3章:网络侦察技术
How to choose the appropriate automated testing tools?
Toast will display a simple prompt message on the program interface
[distributed theory] (I) distributed transactions