# 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
ima
利用七种方法对一个文件夹里面的所有图像进行图像增强实战
最新推荐文章于 2024-03-14 11:27:47 发布
本文将详细介绍如何使用OpenCV和深度学习技术,通过七种不同的图像增强方法,对一个文件夹内的所有图像进行处理,以扩充数据集。这些方法包括旋转、缩放、翻转、噪声注入等,有效提升计算机视觉模型的训练效果。
订阅专栏 解锁全文
1236

被折叠的 条评论
为什么被折叠?



