python进行图片增强

python进行图片增强,第1张

概述import os from PIL import Image from PIL import ImageEnhance def ImageAugument(): path = r‘C:\Users\wy\Desktop\kd‘ files = os.listdir(path) prefix = path + ‘/‘ for file in files: image = Image.open(pr
import os from PIL 
import Image from PIL
import ImageEnhance

def ImageAugument(): 
path = r‘C:\Users\wy\Desktop\kd‘
files = os.Listdir(path)
prefix = path + ‘/‘
for file in files:
image = Image.open(prefix + file)
# image.show()
#亮度增强
enh_bri = ImageEnhance.Brightness(image)
brightness = 1.5
image_brightened = enh_bri.enhance(brightness)
image_brightened.save(prefix + file[0:6] + ‘lightup‘ + ‘.jpg‘)
 
           #色度增强
enh_col = ImageEnhance.color(image)
color = 1.5
image_colored = enh_col.enhance(color)
image_colored.save(prefix + file[0:6] + ‘colorup‘ + ‘.jpg‘)
           #对比度增强 
enh_con = ImageEnhance.Contrast(image)
contrast = 1.3
image_contrasted = enh_con.enhance(contrast)
image_contrasted.save(prefix + file[0:6] + ‘contrastup‘ + ‘.jpg‘)
           #锐度增强 
enh_sha = ImageEnhance.Sharpness(image)
sharpness = 2.8
image_sharped = enh_sha.enhance(sharpness)
image_sharped.save(prefix + file[0:6] + ‘moreSharp‘ + ‘.jpg‘)

if __name__ == ‘__main__‘: ImageAugument()
总结

以上是内存溢出为你收集整理的python进行图片增强全部内容,希望文章能够帮你解决python进行图片增强所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1191647.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-03
下一篇 2022-06-03

发表评论

登录后才能评论

评论列表(0条)

保存